diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index ed6f5b45fa0d1b..c236b4ca3db4c3 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -40,7 +40,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-efr32:73 + image: ghcr.io/project-chip/chip-build-efr32:74 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.gitmodules b/.gitmodules index 0b015f8d14cd16..78a6cabb940d05 100644 --- a/.gitmodules +++ b/.gitmodules @@ -213,17 +213,17 @@ [submodule "third_party/silabs/simplicity_sdk"] path = third_party/silabs/simplicity_sdk url = https://github.com/SiliconLabs/simplicity_sdk.git - branch = v2024.6.0 + branch = v2024.6.1-0 platforms = silabs [submodule "third_party/silabs/wiseconnect-wifi-bt-sdk"] path = third_party/silabs/wiseconnect-wifi-bt-sdk url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk.git - branch = 2.8.2 + branch = 2.10.0 platforms = silabs [submodule "third_party/silabs/wifi_sdk"] path = third_party/silabs/wifi_sdk url = https://github.com/SiliconLabs/wiseconnect.git - branch = v3.3.0 + branch = v3.3.1 platforms = silabs [submodule "editline"] path = third_party/editline/repo diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index fee0d745f6d136..2e2ebe606f089f 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -415,6 +415,8 @@ declare_args() { config("sanitize_address") { defines = [] cflags = [ + "-fsanitize-coverage=inline-8bit-counters,trace-cmp", + "-fno-sanitize-coverage=pc-table", "-fsanitize=address", "-fno-omit-frame-pointer", ] diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults index 45c8894722eeea..80d07150f291d9 100644 --- a/config/telink/chip-module/Kconfig.defaults +++ b/config/telink/chip-module/Kconfig.defaults @@ -219,12 +219,7 @@ config NVS_LOOKUP_CACHE_SIZE config SETTINGS_NVS_SECTOR_SIZE_MULT default 1 -# Set sector counter of NVS -config SETTINGS_NVS_SECTOR_COUNT - default 12 - # Enable OpenThread - config NET_L2_OPENTHREAD default y if !WIFI diff --git a/docs/guides/fabric_synchronization_guide.md b/docs/guides/fabric_synchronization_guide.md index 50fa3202f8ba84..22d616211fbd01 100644 --- a/docs/guides/fabric_synchronization_guide.md +++ b/docs/guides/fabric_synchronization_guide.md @@ -110,6 +110,14 @@ Pair the Ecosystem 2 bridge to Ecosystem 1 with node ID 2: fabricsync add-bridge 2 ``` +This command will initiate the reverse commissioning process. After a few +seconds, you should see the following message, indicating that the local bridge +of Ecosystem 1 has successfully paired with Ecosystem 2 on Endpoint 2: + +``` +>>> A new device is added on Endpoint 2. +``` + ### Pair Light Example to Ecosystem 2 Since Fabric-Bridge also functions as a Matter server, running it alongside the diff --git a/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter b/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter index cb1c102b239f3e..c35b8b62e24ee6 100644 --- a/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter +++ b/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter @@ -1856,7 +1856,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 46debb8a6cd363..4180b1eef78e26 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -5696,7 +5696,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -5847,65 +5847,62 @@ cluster ThermostatUserInterfaceConfiguration = 516 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -5916,16 +5913,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -5957,13 +5965,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -5977,150 +5985,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h b/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h index a80b5fe02d659d..73241be444dbcb 100644 --- a/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h +++ b/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h @@ -360,29 +360,29 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E { case Clusters::ColorControl::Commands::MoveToHue::Id: moveToHueCommand.hue = static_cast(data->args[0]); - moveToHueCommand.direction = static_cast(data->args[1]); + moveToHueCommand.direction = static_cast(data->args[1]); moveToHueCommand.transitionTime = static_cast(data->args[2]); - moveToHueCommand.optionsMask = static_cast(data->args[3]); - moveToHueCommand.optionsOverride = static_cast(data->args[4]); + moveToHueCommand.optionsMask = static_cast(data->args[3]); + moveToHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveToHueCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::MoveHue::Id: - moveHueCommand.moveMode = static_cast(data->args[0]); + moveHueCommand.moveMode = static_cast(data->args[0]); moveHueCommand.rate = static_cast(data->args[1]); - moveHueCommand.optionsMask = static_cast(data->args[2]); - moveHueCommand.optionsOverride = static_cast(data->args[3]); + moveHueCommand.optionsMask = static_cast(data->args[2]); + moveHueCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveHueCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::StepHue::Id: - stepHueCommand.stepMode = static_cast(data->args[0]); + stepHueCommand.stepMode = static_cast(data->args[0]); stepHueCommand.stepSize = static_cast(data->args[1]); stepHueCommand.transitionTime = static_cast(data->args[2]); - stepHueCommand.optionsMask = static_cast(data->args[3]); - stepHueCommand.optionsOverride = static_cast(data->args[4]); + stepHueCommand.optionsMask = static_cast(data->args[3]); + stepHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, stepHueCommand, onSuccess, onFailure); break; @@ -390,27 +390,27 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E case Clusters::ColorControl::Commands::MoveToSaturation::Id: moveToSaturationCommand.saturation = static_cast(data->args[0]); moveToSaturationCommand.transitionTime = static_cast(data->args[1]); - moveToSaturationCommand.optionsMask = static_cast(data->args[2]); - moveToSaturationCommand.optionsOverride = static_cast(data->args[3]); + moveToSaturationCommand.optionsMask = static_cast(data->args[2]); + moveToSaturationCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveToSaturationCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::MoveSaturation::Id: - moveSaturationCommand.moveMode = static_cast(data->args[0]); + moveSaturationCommand.moveMode = static_cast(data->args[0]); moveSaturationCommand.rate = static_cast(data->args[1]); - moveSaturationCommand.optionsMask = static_cast(data->args[2]); - moveSaturationCommand.optionsOverride = static_cast(data->args[3]); + moveSaturationCommand.optionsMask = static_cast(data->args[2]); + moveSaturationCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveSaturationCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::StepSaturation::Id: - stepSaturationCommand.stepMode = static_cast(data->args[0]); + stepSaturationCommand.stepMode = static_cast(data->args[0]); stepSaturationCommand.stepSize = static_cast(data->args[1]); stepSaturationCommand.transitionTime = static_cast(data->args[2]); - stepSaturationCommand.optionsMask = static_cast(data->args[3]); - stepSaturationCommand.optionsOverride = static_cast(data->args[4]); + stepSaturationCommand.optionsMask = static_cast(data->args[3]); + stepSaturationCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, stepSaturationCommand, onSuccess, onFailure); break; @@ -419,8 +419,8 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E moveToHueAndSaturationCommand.hue = static_cast(data->args[0]); moveToHueAndSaturationCommand.saturation = static_cast(data->args[1]); moveToHueAndSaturationCommand.transitionTime = static_cast(data->args[2]); - moveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); - moveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); + moveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); + moveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveToHueAndSaturationCommand, onSuccess, onFailure); break; @@ -429,8 +429,8 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E moveToColorCommand.colorX = static_cast(data->args[0]); moveToColorCommand.colorY = static_cast(data->args[1]); moveToColorCommand.transitionTime = static_cast(data->args[2]); - moveToColorCommand.optionsMask = static_cast(data->args[3]); - moveToColorCommand.optionsOverride = static_cast(data->args[4]); + moveToColorCommand.optionsMask = static_cast(data->args[3]); + moveToColorCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveToColorCommand, onSuccess, onFailure); break; @@ -438,8 +438,8 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E case Clusters::ColorControl::Commands::MoveColor::Id: moveColorCommand.rateX = static_cast(data->args[0]); moveColorCommand.rateY = static_cast(data->args[1]); - moveColorCommand.optionsMask = static_cast(data->args[2]); - moveColorCommand.optionsOverride = static_cast(data->args[3]); + moveColorCommand.optionsMask = static_cast(data->args[2]); + moveColorCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveColorCommand, onSuccess, onFailure); break; @@ -448,8 +448,8 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E stepColorCommand.stepX = static_cast(data->args[0]); stepColorCommand.stepY = static_cast(data->args[1]); stepColorCommand.transitionTime = static_cast(data->args[2]); - stepColorCommand.optionsMask = static_cast(data->args[3]); - stepColorCommand.optionsOverride = static_cast(data->args[4]); + stepColorCommand.optionsMask = static_cast(data->args[3]); + stepColorCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, stepColorCommand, onSuccess, onFailure); break; @@ -457,37 +457,37 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E case Clusters::ColorControl::Commands::MoveToColorTemperature::Id: moveToColorTemperatureCommand.colorTemperatureMireds = static_cast(data->args[0]); moveToColorTemperatureCommand.transitionTime = static_cast(data->args[1]); - moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); - moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); + moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); + moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveToColorTemperatureCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::EnhancedMoveToHue::Id: enhancedMoveToHueCommand.enhancedHue = static_cast(data->args[0]); - enhancedMoveToHueCommand.direction = static_cast(data->args[1]); + enhancedMoveToHueCommand.direction = static_cast(data->args[1]); enhancedMoveToHueCommand.transitionTime = static_cast(data->args[2]); - enhancedMoveToHueCommand.optionsMask = static_cast(data->args[3]); - enhancedMoveToHueCommand.optionsOverride = static_cast(data->args[4]); + enhancedMoveToHueCommand.optionsMask = static_cast(data->args[3]); + enhancedMoveToHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, enhancedMoveToHueCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::EnhancedMoveHue::Id: - enhancedMoveHueCommand.moveMode = static_cast(data->args[0]); + enhancedMoveHueCommand.moveMode = static_cast(data->args[0]); enhancedMoveHueCommand.rate = static_cast(data->args[1]); - enhancedMoveHueCommand.optionsMask = static_cast(data->args[2]); - enhancedMoveHueCommand.optionsOverride = static_cast(data->args[3]); + enhancedMoveHueCommand.optionsMask = static_cast(data->args[2]); + enhancedMoveHueCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, enhancedMoveHueCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::EnhancedStepHue::Id: - enhancedStepHueCommand.stepMode = static_cast(data->args[0]); + enhancedStepHueCommand.stepMode = static_cast(data->args[0]); enhancedStepHueCommand.stepSize = static_cast(data->args[1]); enhancedStepHueCommand.transitionTime = static_cast(data->args[2]); - enhancedStepHueCommand.optionsMask = static_cast(data->args[3]); - enhancedStepHueCommand.optionsOverride = static_cast(data->args[4]); + enhancedStepHueCommand.optionsMask = static_cast(data->args[3]); + enhancedStepHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, enhancedStepHueCommand, onSuccess, onFailure); break; @@ -496,51 +496,51 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E enhancedMoveToHueAndSaturationCommand.enhancedHue = static_cast(data->args[0]); enhancedMoveToHueAndSaturationCommand.saturation = static_cast(data->args[1]); enhancedMoveToHueAndSaturationCommand.transitionTime = static_cast(data->args[2]); - enhancedMoveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); - enhancedMoveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); + enhancedMoveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); + enhancedMoveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, enhancedMoveToHueAndSaturationCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::ColorLoopSet::Id: colorLoopSetCommand.updateFlags = - static_cast>(data->args[0]); - colorLoopSetCommand.action = static_cast(data->args[1]); - colorLoopSetCommand.direction = static_cast(data->args[2]); + static_cast>(data->args[0]); + colorLoopSetCommand.action = static_cast(data->args[1]); + colorLoopSetCommand.direction = static_cast(data->args[2]); colorLoopSetCommand.time = static_cast(data->args[3]); colorLoopSetCommand.startHue = static_cast(data->args[4]); - colorLoopSetCommand.optionsMask = static_cast(data->args[5]); - colorLoopSetCommand.optionsOverride = static_cast(data->args[6]); + colorLoopSetCommand.optionsMask = static_cast(data->args[5]); + colorLoopSetCommand.optionsOverride = static_cast(data->args[6]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, colorLoopSetCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::StopMoveStep::Id: - stopMoveStepCommand.optionsMask = static_cast(data->args[0]); - stopMoveStepCommand.optionsOverride = static_cast(data->args[1]); + stopMoveStepCommand.optionsMask = static_cast(data->args[0]); + stopMoveStepCommand.optionsOverride = static_cast(data->args[1]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, stopMoveStepCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::MoveColorTemperature::Id: - moveColorTemperatureCommand.moveMode = static_cast(data->args[0]); + moveColorTemperatureCommand.moveMode = static_cast(data->args[0]); moveColorTemperatureCommand.rate = static_cast(data->args[1]); moveColorTemperatureCommand.colorTemperatureMinimumMireds = static_cast(data->args[2]); moveColorTemperatureCommand.colorTemperatureMaximumMireds = static_cast(data->args[3]); - moveColorTemperatureCommand.optionsMask = static_cast(data->args[4]); - moveColorTemperatureCommand.optionsOverride = static_cast(data->args[5]); + moveColorTemperatureCommand.optionsMask = static_cast(data->args[4]); + moveColorTemperatureCommand.optionsOverride = static_cast(data->args[5]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveColorTemperatureCommand, onSuccess, onFailure); break; case Clusters::ColorControl::Commands::StepColorTemperature::Id: - stepColorTemperatureCommand.stepMode = static_cast(data->args[0]); + stepColorTemperatureCommand.stepMode = static_cast(data->args[0]); stepColorTemperatureCommand.stepSize = static_cast(data->args[1]); stepColorTemperatureCommand.transitionTime = static_cast(data->args[2]); stepColorTemperatureCommand.colorTemperatureMinimumMireds = static_cast(data->args[3]); stepColorTemperatureCommand.colorTemperatureMaximumMireds = static_cast(data->args[4]); - stepColorTemperatureCommand.optionsMask = static_cast(data->args[5]); - stepColorTemperatureCommand.optionsOverride = static_cast(data->args[6]); + stepColorTemperatureCommand.optionsMask = static_cast(data->args[5]); + stepColorTemperatureCommand.optionsOverride = static_cast(data->args[6]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, stepColorTemperatureCommand, onSuccess, onFailure); break; @@ -577,52 +577,52 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb { case Clusters::ColorControl::Commands::MoveToHue::Id: moveToHueCommand.hue = static_cast(data->args[0]); - moveToHueCommand.direction = static_cast(data->args[1]); + moveToHueCommand.direction = static_cast(data->args[1]); moveToHueCommand.transitionTime = static_cast(data->args[2]); - moveToHueCommand.optionsMask = static_cast(data->args[3]); - moveToHueCommand.optionsOverride = static_cast(data->args[4]); + moveToHueCommand.optionsMask = static_cast(data->args[3]); + moveToHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToHueCommand); break; case Clusters::ColorControl::Commands::MoveHue::Id: - moveHueCommand.moveMode = static_cast(data->args[0]); + moveHueCommand.moveMode = static_cast(data->args[0]); moveHueCommand.rate = static_cast(data->args[1]); - moveHueCommand.optionsMask = static_cast(data->args[2]); - moveHueCommand.optionsOverride = static_cast(data->args[3]); + moveHueCommand.optionsMask = static_cast(data->args[2]); + moveHueCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveHueCommand); break; case Clusters::ColorControl::Commands::StepHue::Id: - stepHueCommand.stepMode = static_cast(data->args[0]); + stepHueCommand.stepMode = static_cast(data->args[0]); stepHueCommand.stepSize = static_cast(data->args[1]); stepHueCommand.transitionTime = static_cast(data->args[2]); - stepHueCommand.optionsMask = static_cast(data->args[3]); - stepHueCommand.optionsOverride = static_cast(data->args[4]); + stepHueCommand.optionsMask = static_cast(data->args[3]); + stepHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, stepHueCommand); break; case Clusters::ColorControl::Commands::MoveToSaturation::Id: moveToSaturationCommand.saturation = static_cast(data->args[0]); moveToSaturationCommand.transitionTime = static_cast(data->args[1]); - moveToSaturationCommand.optionsMask = static_cast(data->args[2]); - moveToSaturationCommand.optionsOverride = static_cast(data->args[3]); + moveToSaturationCommand.optionsMask = static_cast(data->args[2]); + moveToSaturationCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToSaturationCommand); break; case Clusters::ColorControl::Commands::MoveSaturation::Id: - moveSaturationCommand.moveMode = static_cast(data->args[0]); + moveSaturationCommand.moveMode = static_cast(data->args[0]); moveSaturationCommand.rate = static_cast(data->args[1]); - moveSaturationCommand.optionsMask = static_cast(data->args[2]); - moveSaturationCommand.optionsOverride = static_cast(data->args[3]); + moveSaturationCommand.optionsMask = static_cast(data->args[2]); + moveSaturationCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveSaturationCommand); break; case Clusters::ColorControl::Commands::StepSaturation::Id: - stepSaturationCommand.stepMode = static_cast(data->args[0]); + stepSaturationCommand.stepMode = static_cast(data->args[0]); stepSaturationCommand.stepSize = static_cast(data->args[1]); stepSaturationCommand.transitionTime = static_cast(data->args[2]); - stepSaturationCommand.optionsMask = static_cast(data->args[3]); - stepSaturationCommand.optionsOverride = static_cast(data->args[4]); + stepSaturationCommand.optionsMask = static_cast(data->args[3]); + stepSaturationCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, stepSaturationCommand); break; @@ -630,8 +630,8 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb moveToHueAndSaturationCommand.hue = static_cast(data->args[0]); moveToHueAndSaturationCommand.saturation = static_cast(data->args[1]); moveToHueAndSaturationCommand.transitionTime = static_cast(data->args[2]); - moveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); - moveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); + moveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); + moveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToHueAndSaturationCommand); break; @@ -639,16 +639,16 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb moveToColorCommand.colorX = static_cast(data->args[0]); moveToColorCommand.colorY = static_cast(data->args[1]); moveToColorCommand.transitionTime = static_cast(data->args[2]); - moveToColorCommand.optionsMask = static_cast(data->args[3]); - moveToColorCommand.optionsOverride = static_cast(data->args[4]); + moveToColorCommand.optionsMask = static_cast(data->args[3]); + moveToColorCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToColorCommand); break; case Clusters::ColorControl::Commands::MoveColor::Id: moveColorCommand.rateX = static_cast(data->args[0]); moveColorCommand.rateY = static_cast(data->args[1]); - moveColorCommand.optionsMask = static_cast(data->args[2]); - moveColorCommand.optionsOverride = static_cast(data->args[3]); + moveColorCommand.optionsMask = static_cast(data->args[2]); + moveColorCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveColorCommand); break; @@ -656,42 +656,42 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb stepColorCommand.stepX = static_cast(data->args[0]); stepColorCommand.stepY = static_cast(data->args[1]); stepColorCommand.transitionTime = static_cast(data->args[2]); - stepColorCommand.optionsMask = static_cast(data->args[3]); - stepColorCommand.optionsOverride = static_cast(data->args[4]); + stepColorCommand.optionsMask = static_cast(data->args[3]); + stepColorCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, stepColorCommand); break; case Clusters::ColorControl::Commands::MoveToColorTemperature::Id: moveToColorTemperatureCommand.colorTemperatureMireds = static_cast(data->args[0]); moveToColorTemperatureCommand.transitionTime = static_cast(data->args[1]); - moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); - moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); + moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); + moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToColorTemperatureCommand); break; case Clusters::ColorControl::Commands::EnhancedMoveToHue::Id: enhancedMoveToHueCommand.enhancedHue = static_cast(data->args[0]); - enhancedMoveToHueCommand.direction = static_cast(data->args[1]); + enhancedMoveToHueCommand.direction = static_cast(data->args[1]); enhancedMoveToHueCommand.transitionTime = static_cast(data->args[2]); - enhancedMoveToHueCommand.optionsMask = static_cast(data->args[3]); - enhancedMoveToHueCommand.optionsOverride = static_cast(data->args[4]); + enhancedMoveToHueCommand.optionsMask = static_cast(data->args[3]); + enhancedMoveToHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, enhancedMoveToHueCommand); break; case Clusters::ColorControl::Commands::EnhancedMoveHue::Id: - enhancedMoveHueCommand.moveMode = static_cast(data->args[0]); + enhancedMoveHueCommand.moveMode = static_cast(data->args[0]); enhancedMoveHueCommand.rate = static_cast(data->args[1]); - enhancedMoveHueCommand.optionsMask = static_cast(data->args[2]); - enhancedMoveHueCommand.optionsOverride = static_cast(data->args[3]); + enhancedMoveHueCommand.optionsMask = static_cast(data->args[2]); + enhancedMoveHueCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, enhancedMoveHueCommand); break; case Clusters::ColorControl::Commands::EnhancedStepHue::Id: - enhancedStepHueCommand.stepMode = static_cast(data->args[0]); + enhancedStepHueCommand.stepMode = static_cast(data->args[0]); enhancedStepHueCommand.stepSize = static_cast(data->args[1]); enhancedStepHueCommand.transitionTime = static_cast(data->args[2]); - enhancedStepHueCommand.optionsMask = static_cast(data->args[3]); - enhancedStepHueCommand.optionsOverride = static_cast(data->args[4]); + enhancedStepHueCommand.optionsMask = static_cast(data->args[3]); + enhancedStepHueCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, enhancedStepHueCommand); break; @@ -699,48 +699,48 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb enhancedMoveToHueAndSaturationCommand.enhancedHue = static_cast(data->args[0]); enhancedMoveToHueAndSaturationCommand.saturation = static_cast(data->args[1]); enhancedMoveToHueAndSaturationCommand.transitionTime = static_cast(data->args[2]); - enhancedMoveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); - enhancedMoveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); + enhancedMoveToHueAndSaturationCommand.optionsMask = static_cast(data->args[3]); + enhancedMoveToHueAndSaturationCommand.optionsOverride = static_cast(data->args[4]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, enhancedMoveToHueAndSaturationCommand); break; case Clusters::ColorControl::Commands::ColorLoopSet::Id: colorLoopSetCommand.updateFlags = - static_cast>(data->args[0]); - colorLoopSetCommand.action = static_cast(data->args[1]); - colorLoopSetCommand.direction = static_cast(data->args[2]); + static_cast>(data->args[0]); + colorLoopSetCommand.action = static_cast(data->args[1]); + colorLoopSetCommand.direction = static_cast(data->args[2]); colorLoopSetCommand.time = static_cast(data->args[3]); colorLoopSetCommand.startHue = static_cast(data->args[4]); - colorLoopSetCommand.optionsMask = static_cast(data->args[5]); - colorLoopSetCommand.optionsOverride = static_cast(data->args[6]); + colorLoopSetCommand.optionsMask = static_cast(data->args[5]); + colorLoopSetCommand.optionsOverride = static_cast(data->args[6]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, colorLoopSetCommand); break; case Clusters::ColorControl::Commands::StopMoveStep::Id: - stopMoveStepCommand.optionsMask = static_cast(data->args[0]); - stopMoveStepCommand.optionsOverride = static_cast(data->args[1]); + stopMoveStepCommand.optionsMask = static_cast(data->args[0]); + stopMoveStepCommand.optionsOverride = static_cast(data->args[1]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, stopMoveStepCommand); break; case Clusters::ColorControl::Commands::MoveColorTemperature::Id: - moveColorTemperatureCommand.moveMode = static_cast(data->args[0]); + moveColorTemperatureCommand.moveMode = static_cast(data->args[0]); moveColorTemperatureCommand.rate = static_cast(data->args[1]); moveColorTemperatureCommand.colorTemperatureMinimumMireds = static_cast(data->args[2]); moveColorTemperatureCommand.colorTemperatureMaximumMireds = static_cast(data->args[3]); - moveColorTemperatureCommand.optionsMask = static_cast(data->args[4]); - moveColorTemperatureCommand.optionsOverride = static_cast(data->args[5]); + moveColorTemperatureCommand.optionsMask = static_cast(data->args[4]); + moveColorTemperatureCommand.optionsOverride = static_cast(data->args[5]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveColorTemperatureCommand); break; case Clusters::ColorControl::Commands::StepColorTemperature::Id: - stepColorTemperatureCommand.stepMode = static_cast(data->args[0]); + stepColorTemperatureCommand.stepMode = static_cast(data->args[0]); stepColorTemperatureCommand.stepSize = static_cast(data->args[1]); stepColorTemperatureCommand.transitionTime = static_cast(data->args[2]); stepColorTemperatureCommand.colorTemperatureMinimumMireds = static_cast(data->args[3]); stepColorTemperatureCommand.colorTemperatureMaximumMireds = static_cast(data->args[4]); - stepColorTemperatureCommand.optionsMask = static_cast(data->args[5]); - stepColorTemperatureCommand.optionsOverride = static_cast(data->args[6]); + stepColorTemperatureCommand.optionsMask = static_cast(data->args[5]); + stepColorTemperatureCommand.optionsOverride = static_cast(data->args[6]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, stepColorTemperatureCommand); break; } diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 1444915c368b6b..363da41015d0b0 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -4130,7 +4130,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -4281,65 +4281,62 @@ cluster ThermostatUserInterfaceConfiguration = 516 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -4350,16 +4347,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -4391,13 +4399,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -4411,150 +4419,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter index ed130f29318062..d47b3a90922d57 100644 --- a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter +++ b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter @@ -1779,7 +1779,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter index 961f40352b1052..d8758b3043edaa 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter @@ -1715,65 +1715,62 @@ cluster GroupKeyManagement = 63 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -1784,16 +1781,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -1825,13 +1833,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -1845,150 +1853,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter index d9841f769a79dd..0ef1c969727a6d 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter @@ -1816,65 +1816,62 @@ cluster FixedLabel = 64 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -1885,16 +1882,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -1926,13 +1934,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -1946,150 +1954,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index ec62d4504f8601..84b5d949b6eeba 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -2136,7 +2136,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter index 95e0ba20d4adcb..20b7d6b80d35f5 100644 --- a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter +++ b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter @@ -1719,7 +1719,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 6c27235c7d3ade..ae6441c2eaebea 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -1939,7 +1939,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/common/imgui_ui/windows/light.cpp b/examples/common/imgui_ui/windows/light.cpp index 86899e044b2ed1..f4950739e6c416 100644 --- a/examples/common/imgui_ui/windows/light.cpp +++ b/examples/common/imgui_ui/windows/light.cpp @@ -155,14 +155,14 @@ void Light::Render() ImGui::Text("Color Control:"); ImGui::Indent(); const char * mode = // based on ColorMode attribute: spec 3.2.7.9 - (mColorMode == kColorModeCurrentHueAndCurrentSaturation) ? "Hue/Saturation" - : (mColorMode == kColorModeCurrentXAndCurrentY) ? "X/Y" - : (mColorMode == kColorModeColorTemperature) ? "Temperature/Mireds" - : "UNKNOWN"; + (mColorMode == ColorControl::ColorModeEnum::kCurrentHueAndCurrentSaturation) ? "Hue/Saturation" + : (mColorMode == ColorControl::ColorModeEnum::kCurrentXAndCurrentY) ? "X/Y" + : (mColorMode == ColorControl::ColorModeEnum::kColorTemperatureMireds) ? "Temperature/Mireds" + : "UNKNOWN"; ImGui::Text("Mode: %s", mode); - if (mColorMode == kColorModeCurrentHueAndCurrentSaturation) + if (mColorMode == ColorControl::ColorModeEnum::kCurrentHueAndCurrentSaturation) { const float hueDegrees = (mColorHue * 360.0f) / 254.0f; const float saturationPercent = 100.0f * (mColorSaturation / 254.0f); @@ -173,12 +173,12 @@ void Light::Render() ImGui::ColorButton("LightColor", HueSaturationToColor(hueDegrees, saturationPercent), 0 /* ImGuiColorEditFlags_* */, ImVec2(80, 80)); } - else if (mColorMode == kColorModeCurrentXAndCurrentY) + else if (mColorMode == ColorControl::ColorModeEnum::kCurrentXAndCurrentY) { ImGui::Text("Current X: %d", mColorX); ImGui::Text("Current Y: %d", mColorY); } - else if (mColorMode == kColorModeColorTemperature) + else if (mColorMode == ColorControl::ColorModeEnum::kColorTemperatureMireds) { ImGui::Text("Color Temperature Mireds: %d", mColorTemperatureMireds); } diff --git a/examples/common/imgui_ui/windows/light.h b/examples/common/imgui_ui/windows/light.h index 20942373d3111c..242f6c98b81889 100644 --- a/examples/common/imgui_ui/windows/light.h +++ b/examples/common/imgui_ui/windows/light.h @@ -62,7 +62,8 @@ class Light : public Window uint16_t mLevelRemainingTime10sOfSec = 0; // Color control - uint8_t mColorMode = kColorModeCurrentHueAndCurrentSaturation; + chip::app::Clusters::ColorControl::ColorModeEnum mColorMode = + chip::app::Clusters::ColorControl::ColorModeEnum::kCurrentHueAndCurrentSaturation; uint8_t mColorHue = 0; uint8_t mColorSaturation = 0; uint16_t mColorX = 0; diff --git a/examples/common/pigweed/protos/fabric_admin_service.proto b/examples/common/pigweed/protos/fabric_admin_service.proto index 3c311493d1c6f3..3df3e2a7aa5f5f 100644 --- a/examples/common/pigweed/protos/fabric_admin_service.proto +++ b/examples/common/pigweed/protos/fabric_admin_service.proto @@ -19,7 +19,9 @@ message DeviceCommissioningInfo { uint32 discriminator = 1; uint32 iterations = 2; uint32 setup_pin = 3; - bytes salt = 4; + uint32 vendor_id = 4; + uint32 product_id = 5; + bytes salt = 6; } message KeepActiveParameters { diff --git a/examples/fabric-admin/commands/pairing/DeviceSynchronization.cpp b/examples/fabric-admin/commands/pairing/DeviceSynchronization.cpp index 3974761fdc4bc2..69ca9cdb722b23 100644 --- a/examples/fabric-admin/commands/pairing/DeviceSynchronization.cpp +++ b/examples/fabric-admin/commands/pairing/DeviceSynchronization.cpp @@ -24,6 +24,7 @@ #include #include +#include using namespace ::chip; using namespace ::chip::app; @@ -120,7 +121,10 @@ void DeviceSynchronizer::OnReportEnd() { // Report end is at the end of all attributes (success) #if defined(PW_RPC_ENABLED) - AddSynchronizedDevice(mCurrentDeviceData); + if (!DeviceMgr().IsCurrentBridgeDevice(mCurrentDeviceData.node_id)) + { + AddSynchronizedDevice(mCurrentDeviceData); + } #else ChipLogError(NotSpecified, "Cannot synchronize device with fabric bridge: RPC not enabled"); #endif diff --git a/examples/fabric-admin/device_manager/DeviceManager.h b/examples/fabric-admin/device_manager/DeviceManager.h index d3b47c4b332276..fa94f3d09d18cf 100644 --- a/examples/fabric-admin/device_manager/DeviceManager.h +++ b/examples/fabric-admin/device_manager/DeviceManager.h @@ -75,6 +75,15 @@ class DeviceManager : public PairingDelegate void RemoveSyncedDevice(chip::NodeId nodeId); + /** + * @brief Determines whether a given nodeId corresponds to the "current bridge device," either local or remote. + * + * @param nodeId The ID of the node being checked. + * + * @return true if the nodeId matches either the local or remote bridge device; otherwise, false. + */ + bool IsCurrentBridgeDevice(chip::NodeId nodeId) const { return nodeId == mLocalBridgeNodeId || nodeId == mRemoteBridgeNodeId; } + /** * @brief Open the commissioning window for a specific device within its own fabric. * @@ -156,11 +165,11 @@ class DeviceManager : public PairingDelegate void HandleCommandResponse(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader & data); - void OnDeviceRemoved(chip::NodeId deviceId, CHIP_ERROR err) override; - private: friend DeviceManager & DeviceMgr(); + void OnDeviceRemoved(chip::NodeId deviceId, CHIP_ERROR err) override; + void RequestCommissioningApproval(); void HandleReadSupportedDeviceCategories(chip::TLV::TLVReader & data); diff --git a/examples/fabric-admin/rpc/RpcServer.cpp b/examples/fabric-admin/rpc/RpcServer.cpp index f240feda22a2d4..fca25c25a1301a 100644 --- a/examples/fabric-admin/rpc/RpcServer.cpp +++ b/examples/fabric-admin/rpc/RpcServer.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #if defined(PW_RPC_FABRIC_ADMIN_SERVICE) && PW_RPC_FABRIC_ADMIN_SERVICE @@ -47,20 +47,32 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate public: void OnCheckInCompleted(const chip::app::ICDClientInfo & clientInfo) override { - chip::NodeId nodeId = clientInfo.peer_node.GetNodeId(); - auto it = mPendingKeepActiveTimesMs.find(nodeId); - VerifyOrReturn(it != mPendingKeepActiveTimesMs.end()); - // TODO(#33221): We also need a mechanism here to drop KeepActive - // request if they were recieved over 60 mins ago. - uint32_t stayActiveDurationMs = it->second; + // Needs for accessing mPendingCheckIn + assertChipStackLockedByCurrentThread(); + NodeId nodeId = clientInfo.peer_node.GetNodeId(); + auto it = mPendingCheckIn.find(nodeId); + VerifyOrReturn(it != mPendingCheckIn.end()); + + KeepActiveDataForCheckIn checkInData = it->second; + // Removed from pending map as check-in from this node has occured and we will handle the pending KeepActive + // request. + mPendingCheckIn.erase(nodeId); + + auto timeNow = System::SystemClock().GetMonotonicTimestamp(); + if (timeNow > checkInData.mRequestExpiryTimestamp) + { + ChipLogError( + NotSpecified, + "ICD check-in for device we have been waiting, came after KeepActive expiry. Reqeust dropped for Node ID: 0x%lx", + nodeId); + return; + } // TODO(#33221): If there is a failure in sending the message this request just gets dropped. // Work to see if there should be update to spec on whether some sort of failure later on // Should be indicated in some manner, or identify a better recovery mechanism here. - mPendingKeepActiveTimesMs.erase(nodeId); - auto onDone = [=](uint32_t promisedActiveDuration) { ActiveChanged(nodeId, promisedActiveDuration); }; - CHIP_ERROR err = StayActiveSender::SendStayActiveCommand(stayActiveDurationMs, clientInfo.peer_node, + CHIP_ERROR err = StayActiveSender::SendStayActiveCommand(checkInData.mStayActiveDurationMs, clientInfo.peer_node, chip::app::InteractionModelEngine::GetInstance(), onDone); if (err != CHIP_NO_ERROR) { @@ -103,16 +115,18 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate setupPayload.setUpPINCode = request.setup_pin; setupPayload.version = 0; + setupPayload.vendorID = request.vendor_id; + setupPayload.productID = request.product_id; setupPayload.rendezvousInformation.SetValue(RendezvousInformationFlag::kOnNetwork); SetupDiscriminator discriminator{}; discriminator.SetLongValue(request.discriminator); setupPayload.discriminator = discriminator; - char payloadBuffer[kMaxManualCodeLength + 1]; - MutableCharSpan manualCode(payloadBuffer); + QRCodeSetupPayloadGenerator generator(setupPayload); + std::string code; + CHIP_ERROR error = generator.payloadBase38RepresentationWithAutoTLVBuffer(code); - CHIP_ERROR error = ManualSetupPayloadGenerator(setupPayload).payloadDecimalStringRepresentation(manualCode); if (error == CHIP_NO_ERROR) { NodeId nodeId = DeviceMgr().GetNextAvailableNodeId(); @@ -121,11 +135,11 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate // RequestCommissioningApproval, you need to wait for it to open a commissioning window on its bridge. usleep(kCommissionPrepareTimeMs * 1000); - DeviceMgr().PairRemoteDevice(nodeId, payloadBuffer); + DeviceMgr().PairRemoteDevice(nodeId, code.c_str()); } else { - ChipLogError(NotSpecified, "Unable to generate manual code for setup payload: %" CHIP_ERROR_FORMAT, error.Format()); + ChipLogError(NotSpecified, "Unable to generate pairing code for setup payload: %" CHIP_ERROR_FORMAT, error.Format()); } return pw::OkStatus(); @@ -145,10 +159,24 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate void ScheduleSendingKeepActiveOnCheckIn(chip::NodeId nodeId, uint32_t stayActiveDurationMs) { - mPendingKeepActiveTimesMs[nodeId] = stayActiveDurationMs; + // Needs for accessing mPendingCheckIn + assertChipStackLockedByCurrentThread(); + + auto timeNow = System::SystemClock().GetMonotonicTimestamp(); + // Spec says we should expire the request 60 mins after we get it + System::Clock::Timestamp expiryTimestamp = timeNow + System::Clock::Seconds64(60 * 60); + KeepActiveDataForCheckIn checkInData = { .mStayActiveDurationMs = stayActiveDurationMs, + .mRequestExpiryTimestamp = expiryTimestamp }; + mPendingCheckIn[nodeId] = checkInData; } private: + struct KeepActiveDataForCheckIn + { + uint32_t mStayActiveDurationMs = 0; + System::Clock::Timestamp mRequestExpiryTimestamp; + }; + struct KeepActiveWorkData { KeepActiveWorkData(FabricAdmin * fabricAdmin, chip::NodeId nodeId, uint32_t stayActiveDurationMs) : @@ -167,8 +195,10 @@ class FabricAdmin final : public rpc::FabricAdmin, public IcdManager::Delegate chip::Platform::Delete(data); } - // Modifications to mPendingKeepActiveTimesMs should be done on the MatterEventLoop thread - std::map mPendingKeepActiveTimesMs; + // Modifications to mPendingCheckIn should be done on the MatterEventLoop thread + // otherwise we would need a mutex protecting this data to prevent race as this + // data is accessible by both RPC thread and Matter eventloop. + std::unordered_map mPendingCheckIn; }; FabricAdmin fabric_admin_service; diff --git a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn index 7f2fbcbbfe0556..157032f8f93c19 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn +++ b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn @@ -41,10 +41,12 @@ source_set("fabric-bridge-lib") { public_configs = [ ":config" ] sources = [ + "include/BridgedAdministratorCommissioning.h", "include/BridgedDevice.h", "include/BridgedDeviceBasicInformationImpl.h", "include/BridgedDeviceManager.h", "include/CHIPProjectAppConfig.h", + "src/BridgedAdministratorCommissioning.cpp", "src/BridgedDevice.cpp", "src/BridgedDeviceBasicInformationImpl.cpp", "src/BridgedDeviceManager.cpp", diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedAdministratorCommissioning.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedAdministratorCommissioning.h new file mode 100644 index 00000000000000..06fd9026d44225 --- /dev/null +++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedAdministratorCommissioning.h @@ -0,0 +1,58 @@ +/* + * 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 + +/** + * @brief CADMIN cluster implementation for handling attribute interactions of bridged device endpoints. + * + * The current Administrator Commissioning Cluster server's zap generated code will automatically + * register an Attribute Access Interface for the root node endpoint implementation. In order to + * properly respond to a read attribute for bridged devices we are representing, we override the + * currently registered Attribute Interface such that we are first to receive any read attribute + * request on Administrator Commissioning Cluster, and if it is not an endpoint for a device we + * are a bridge for we redirect to the default cluster server implementation of Administrator + * Commissioning Cluster. + */ +class BridgedAdministratorCommissioning : public chip::app::AttributeAccessInterface +{ +public: + // Register for the AdministratorCommissioning cluster on all endpoints. + BridgedAdministratorCommissioning() : + AttributeAccessInterface(chip::NullOptional, chip::app::Clusters::AdministratorCommissioning::Id) + {} + + CHIP_ERROR Init(); + + CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::app::AttributeValueEncoder & aEncoder) override; + + // We do not allow writing to CADMIN attributes of a bridged device endpoint. We simply redirect + // write requests to the original attribute interface. + CHIP_ERROR Write(const chip::app::ConcreteDataAttributePath & aPath, chip::app::AttributeValueDecoder & aDecoder) override + { + VerifyOrDie(mOriginalAttributeInterface); + return mOriginalAttributeInterface->Write(aPath, aDecoder); + } + +private: + // If mOriginalAttributeInterface is removed from here, the class description needs to be updated + // to reflect this change. + chip::app::AttributeAccessInterface * mOriginalAttributeInterface = nullptr; +}; diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h index 3dab8d3b16b2d6..7081278f4dc0f3 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h +++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h @@ -18,6 +18,7 @@ #pragma once +#include #include #include @@ -40,6 +41,14 @@ class BridgedDevice std::string softwareVersionString; }; + struct AdminCommissioningAttributes + { + chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum commissioningWindowStatus = + chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kWindowNotOpen; + std::optional openerFabricIndex = std::nullopt; + std::optional openerVendorId = std::nullopt; + }; + BridgedDevice(chip::NodeId nodeId); virtual ~BridgedDevice() = default; @@ -59,6 +68,8 @@ class BridgedDevice [[nodiscard]] const BridgedAttributes & GetBridgedAttributes() const { return mAttributes; } void SetBridgedAttributes(const BridgedAttributes & value) { mAttributes = value; } + // TODO(#35077): Need to allow mAdminCommissioningAttributes to be set from fabric-admin. + const AdminCommissioningAttributes & GetAdminCommissioningAttributes() const { return mAdminCommissioningAttributes; } /// Convenience method to set just the unique id of a bridged device as it /// is one of the few attributes that is not always bulk-set @@ -73,4 +84,5 @@ class BridgedDevice chip::EndpointId mParentEndpointId = 0; BridgedAttributes mAttributes; + AdminCommissioningAttributes mAdminCommissioningAttributes; }; diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedAdministratorCommissioning.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedAdministratorCommissioning.cpp new file mode 100644 index 00000000000000..a0d87cbb3b81ef --- /dev/null +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedAdministratorCommissioning.cpp @@ -0,0 +1,81 @@ +/* + * 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 "BridgedAdministratorCommissioning.h" + +#include "BridgedDevice.h" +#include "BridgedDeviceManager.h" +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::AdministratorCommissioning; + +CHIP_ERROR BridgedAdministratorCommissioning::Init() +{ + // We expect initialization after emberAfInit(). This allows us to unregister the existing + // AccessAttributeInterface for AdministratorCommissioning and register ourselves, ensuring we + // get the callback for reading attribute. If the read is not intended for a bridged device we will + // forward it to the original attribute interface that we are unregistering. + mOriginalAttributeInterface = AttributeAccessInterfaceRegistry::Instance().Get(kRootEndpointId, AdministratorCommissioning::Id); + VerifyOrReturnError(mOriginalAttributeInterface, CHIP_ERROR_INTERNAL); + AttributeAccessInterfaceRegistry::Instance().Unregister(mOriginalAttributeInterface); + VerifyOrDie(AttributeAccessInterfaceRegistry::Instance().Register(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR BridgedAdministratorCommissioning::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + VerifyOrDie(aPath.mClusterId == Clusters::AdministratorCommissioning::Id); + EndpointId endpointId = aPath.mEndpointId; + BridgedDevice * device = BridgeDeviceMgr().GetDevice(endpointId); + + if (!device) + { + VerifyOrDie(mOriginalAttributeInterface); + return mOriginalAttributeInterface->Read(aPath, aEncoder); + } + auto attr = device->GetAdminCommissioningAttributes(); + + switch (aPath.mAttributeId) + { + case Attributes::WindowStatus::Id: { + return aEncoder.Encode(attr.commissioningWindowStatus); + } + case Attributes::AdminFabricIndex::Id: { + DataModel::Nullable encodeableFabricIndex = DataModel::NullNullable; + if (attr.openerFabricIndex.has_value()) + { + encodeableFabricIndex.SetNonNull(attr.openerFabricIndex.value()); + } + return aEncoder.Encode(encodeableFabricIndex); + } + case Attributes::AdminVendorId::Id: { + DataModel::Nullable encodeableVendorId = DataModel::NullNullable; + if (attr.openerVendorId.has_value()) + { + encodeableVendorId.SetNonNull(attr.openerVendorId.value()); + } + return aEncoder.Encode(encodeableVendorId); + } + default: + break; + } + + return CHIP_NO_ERROR; +} diff --git a/examples/fabric-bridge-app/linux/CommissionerControl.cpp b/examples/fabric-bridge-app/linux/CommissionerControl.cpp index 9f3180668de42c..3613aeec9305e4 100644 --- a/examples/fabric-bridge-app/linux/CommissionerControl.cpp +++ b/examples/fabric-bridge-app/linux/CommissionerControl.cpp @@ -137,7 +137,8 @@ CHIP_ERROR CommissionerControlDelegate::HandleCommissionNode(const Commissioning .SetTimeout(params.commissioningTimeout) .SetDiscriminator(params.discriminator) .SetIteration(params.iterations) - .SetSalt(params.salt)); + .SetSalt(params.salt), + mVendorId, mProductId); #else ChipLogProgress(NotSpecified, "Failed to reverse commission bridge: PW_RPC_FABRIC_BRIDGE_SERVICE not defined"); return CHIP_ERROR_NOT_IMPLEMENTED; diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp index b3c82303beb8f5..817479d8482af1 100644 --- a/examples/fabric-bridge-app/linux/RpcClient.cpp +++ b/examples/fabric-bridge-app/linux/RpcClient.cpp @@ -163,12 +163,14 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams para } CHIP_ERROR -CommissionNode(chip::Controller::CommissioningWindowPasscodeParams params) +CommissionNode(chip::Controller::CommissioningWindowPasscodeParams params, VendorId vendorId, uint16_t productId) { chip_rpc_DeviceCommissioningInfo device; device.setup_pin = params.GetSetupPIN(); device.discriminator = params.GetDiscriminator(); device.iterations = params.GetIteration(); + device.vendor_id = vendorId; + device.product_id = productId; VerifyOrReturnError(params.GetSalt().size() <= sizeof(device.salt.bytes), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(device.salt.bytes, params.GetSalt().data(), params.GetSalt().size()); diff --git a/examples/fabric-bridge-app/linux/include/RpcClient.h b/examples/fabric-bridge-app/linux/include/RpcClient.h index 87ccba24f645dc..c7628a8c3ba73c 100644 --- a/examples/fabric-bridge-app/linux/include/RpcClient.h +++ b/examples/fabric-bridge-app/linux/include/RpcClient.h @@ -60,12 +60,20 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams para /** * Commission a node using the specified parameters. * - * @param params Params for commissioning the device using passcode. + * This function initiates the commissioning process for a node, utilizing + * the provided passcode parameters, vendor ID, and product ID. + * + * @param params Parameters required for commissioning the device using passcode. + * @param vendorId The Vendor ID (VID) of the device being commissioned. This identifies + * the manufacturer of the device. + * @param productId The Product ID (PID) of the device being commissioned. This identifies + * the specific product within the vendor's lineup. + * * @return CHIP_ERROR An error code indicating the success or failure of the operation. - * - CHIP_NO_ERROR: The RPC command was successfully sent. - * - CHIP_ERROR_INTERNAL: An internal error occurred. + * - CHIP_NO_ERROR: The RPC command was successfully sent and the commissioning process was initiated. + * - CHIP_ERROR_INTERNAL: An internal error occurred during the preparation or sending of the command. */ CHIP_ERROR -CommissionNode(chip::Controller::CommissioningWindowPasscodeParams params); +CommissionNode(chip::Controller::CommissioningWindowPasscodeParams params, chip::VendorId vendorId, uint16_t productId); CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDurationMs); diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index 3b6502421045f8..eeb290210caa6b 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -18,6 +18,7 @@ #include +#include "BridgedAdministratorCommissioning.h" #include "BridgedDevice.h" #include "BridgedDeviceBasicInformationImpl.h" #include "BridgedDeviceManager.h" @@ -234,6 +235,7 @@ void BridgedDeviceInformationCommandHandler::InvokeCommand(HandlerContext & hand handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, status); } +BridgedAdministratorCommissioning gBridgedAdministratorCommissioning; AdministratorCommissioningCommandHandler gAdministratorCommissioningCommandHandler; BridgedDeviceInformationCommandHandler gBridgedDeviceInformationCommandHandler; @@ -258,6 +260,7 @@ void ApplicationInit() pollingThread.detach(); BridgeDeviceMgr().Init(); + VerifyOrDie(gBridgedAdministratorCommissioning.Init() == CHIP_NO_ERROR); VerifyOrDieWithMsg(CommissionerControlInit() == CHIP_NO_ERROR, NotSpecified, "Failed to initialize Commissioner Control Server"); 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 8cd9c653a75bb5..3909b6073c8b9c 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 @@ -2502,65 +2502,62 @@ provisional cluster ScenesManagement = 98 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -2571,16 +2568,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2612,13 +2620,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2632,150 +2640,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/light-switch-app/qpg/zap/switch.matter b/examples/light-switch-app/qpg/zap/switch.matter index 6924e96503d0c6..c93a50bb03e2dc 100644 --- a/examples/light-switch-app/qpg/zap/switch.matter +++ b/examples/light-switch-app/qpg/zap/switch.matter @@ -2558,65 +2558,62 @@ provisional cluster ScenesManagement = 98 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -2627,16 +2624,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2668,13 +2676,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2688,150 +2696,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter index 331f7e79cadfe9..30f4d63c6a4e1e 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-ethernet.matter @@ -1855,65 +1855,62 @@ cluster UserLabel = 65 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -1924,16 +1921,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -1965,13 +1973,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -1985,150 +1993,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter index f6bb26ec689619..2abf5c7251711d 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter @@ -1979,65 +1979,62 @@ cluster UserLabel = 65 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -2048,16 +2045,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2089,13 +2097,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2109,150 +2117,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter index 9dee0bdcdb040d..b9dfeee6321680 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter @@ -1890,65 +1890,62 @@ cluster UserLabel = 65 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -1959,16 +1956,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2000,13 +2008,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2020,150 +2028,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 5ddd7071470692..df7f0dfe4d9a55 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -2310,65 +2310,62 @@ provisional cluster ScenesManagement = 98 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -2379,16 +2376,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2420,13 +2428,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2440,150 +2448,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/lighting-app/qpg/zap/light.matter b/examples/lighting-app/qpg/zap/light.matter index 6add567a134707..35e00056736443 100644 --- a/examples/lighting-app/qpg/zap/light.matter +++ b/examples/lighting-app/qpg/zap/light.matter @@ -1918,65 +1918,62 @@ cluster UserLabel = 65 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -1987,16 +1984,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2028,13 +2036,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2048,150 +2056,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ 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 d0e06e94f94dac..f4c2928a35778e 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter @@ -2014,65 +2014,62 @@ provisional cluster ScenesManagement = 98 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -2083,16 +2080,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2124,13 +2132,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2144,150 +2152,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ 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 a9d48f8ae85b3c..59919ee6b48737 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter @@ -2305,65 +2305,62 @@ provisional cluster ScenesManagement = 98 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -2374,16 +2371,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -2415,13 +2423,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -2435,150 +2443,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/lighting-app/tizen/src/DBusInterface.cpp b/examples/lighting-app/tizen/src/DBusInterface.cpp index 50dbd37930b47f..36c0f19c35bb7a 100644 --- a/examples/lighting-app/tizen/src/DBusInterface.cpp +++ b/examples/lighting-app/tizen/src/DBusInterface.cpp @@ -217,11 +217,11 @@ void DBusInterface::InitOnOff() void DBusInterface::InitColor() { { - uint8_t value = 0; - auto status = Clusters::ColorControl::Attributes::ColorMode::Get(mEndpointId, &value); + auto value = Clusters::ColorControl::ColorModeEnum::kCurrentHueAndCurrentSaturation; + auto status = Clusters::ColorControl::Attributes::ColorMode::Get(mEndpointId, &value); VerifyOrReturn(status == Protocols::InteractionModel::Status::Success, ChipLogError(NotSpecified, "Error getting ColorMode: 0x%x", to_underlying(status))); - light_app_color_control_set_color_mode(mIfaceColorControl, value); + light_app_color_control_set_color_mode(mIfaceColorControl, to_underlying(value)); } { uint16_t value = 0; diff --git a/examples/lighting-app/tizen/src/main.cpp b/examples/lighting-app/tizen/src/main.cpp index c1cda62a2378d5..040a8a5fcb231f 100644 --- a/examples/lighting-app/tizen/src/main.cpp +++ b/examples/lighting-app/tizen/src/main.cpp @@ -123,7 +123,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & void emberAfColorControlClusterInitCallback(EndpointId endpoint) { // Set the color mode to color temperature. - Clusters::ColorControl::Attributes::ColorMode::Set(endpoint, ColorControlServer::EnhancedColorMode::kColorTemperature); + Clusters::ColorControl::Attributes::ColorMode::Set(endpoint, Clusters::ColorControl::ColorModeEnum::kColorTemperatureMireds); // Preserve the state of the color temperature attribute across reboots. Clusters::ColorControl::Attributes::StartUpColorTemperatureMireds::SetNull(endpoint); } diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index b72a4b280351b9..33521a7a93fa75 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -5414,7 +5414,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -5769,7 +5769,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -5872,65 +5872,62 @@ cluster ThermostatUserInterfaceConfiguration = 516 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -5941,16 +5938,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -5982,13 +5990,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -6002,150 +6010,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ @@ -6192,65 +6200,62 @@ cluster ColorControl = 768 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -6261,16 +6266,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -6302,13 +6318,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -6322,150 +6338,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 41421c7e917d0e..86d20b24a4f629 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -5371,7 +5371,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -5726,7 +5726,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -5829,65 +5829,62 @@ cluster ThermostatUserInterfaceConfiguration = 516 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -5898,16 +5895,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -5939,13 +5947,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -5959,150 +5967,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ @@ -6149,65 +6157,62 @@ cluster ColorControl = 768 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -6218,16 +6223,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -6259,13 +6275,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -6279,150 +6295,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/examples/platform/esp32/external_platform/ESP32_custom/WiFiDnssdImpl.cpp b/examples/platform/esp32/external_platform/ESP32_custom/WiFiDnssdImpl.cpp deleted file mode 120000 index 6ca9fce6a3730d..00000000000000 --- a/examples/platform/esp32/external_platform/ESP32_custom/WiFiDnssdImpl.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../../../src/platform/ESP32/WiFiDnssdImpl.cpp \ No newline at end of file diff --git a/examples/platform/esp32/external_platform/ESP32_custom/WiFiDnssdImpl.h b/examples/platform/esp32/external_platform/ESP32_custom/WiFiDnssdImpl.h deleted file mode 120000 index 213e49958733a8..00000000000000 --- a/examples/platform/esp32/external_platform/ESP32_custom/WiFiDnssdImpl.h +++ /dev/null @@ -1 +0,0 @@ -../../../../../src/platform/ESP32/WiFiDnssdImpl.h \ No newline at end of file diff --git a/examples/platform/silabs/FreeRTOSConfig.h b/examples/platform/silabs/FreeRTOSConfig.h index d2805c40654632..b27c775d9b7a54 100644 --- a/examples/platform/silabs/FreeRTOSConfig.h +++ b/examples/platform/silabs/FreeRTOSConfig.h @@ -150,7 +150,7 @@ extern uint32_t SystemCoreClock; #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 70 #define configPRE_SLEEP_PROCESSING(x) #define configPOST_SLEEP_PROCESSING(x) -#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) sl_si91x_pre_supress_ticks_and_sleep(&x) +#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) #else #define configUSE_TICKLESS_IDLE 0 #endif // SL_CATALOG_POWER_MANAGER_PRESENT diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp index bfdedbfe82bb13..03b51540cf4b6d 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp @@ -15,6 +15,10 @@ * limitations under the License. */ +/* + * This file implements the interface to the wifi sdk + */ + #include #include #include @@ -23,38 +27,44 @@ #include "sl_matter_wifi_config.h" #endif // SL_MATTER_GN_BUILD +#include "FreeRTOS.h" +#include "ble_config.h" +#include "dhcp_client.h" +#include "event_groups.h" +#include "sl_board_configuration.h" #include "sl_status.h" +#include "task.h" +#include "wfx_host_events.h" +#include "wfx_rsi.h" #include #include #include -#include "FreeRTOS.h" -#include "event_groups.h" -#include "sl_board_configuration.h" extern "C" { +#include "sl_net.h" +#include "sl_si91x_driver.h" +#include "sl_si91x_host_interface.h" #include "sl_si91x_types.h" +#include "sl_wifi.h" +#include "sl_wifi_callback_framework.h" #include "sl_wifi_constants.h" #include "sl_wifi_types.h" #include "sl_wlan_config.h" +#include "wfx_host_events.h" +#if SL_MBEDTLS_USE_TINYCRYPT +#include "sl_si91x_constants.h" +#include "sl_si91x_trng.h" +#endif // SL_MBEDTLS_USE_TINYCRYPT } -#include "task.h" #if (EXP_BOARD) #include "rsi_bt_common_apis.h" #endif -#include "ble_config.h" - #if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE #include "rsi_rom_power_save.h" #include "sl_si91x_button_pin_config.h" -#if DISPLAY_ENABLED -#include "sl_memlcd.h" -#endif // DISPLAY_ENABLED -extern "C" { -#include "sl_si91x_driver.h" -#include "sl_si91x_m4_ps.h" -} +#include "sl_si91x_power_manager.h" namespace { // TODO: should be removed once we are getting the press interrupt for button 0 with sleep @@ -67,9 +77,6 @@ bool ps_requirement_added = false; } // namespace #endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE -#include "dhcp_client.h" -#include "wfx_host_events.h" -#include "wfx_rsi.h" #define ADV_SCAN_THRESHOLD -40 #define ADV_RSSI_TOLERANCE_THRESHOLD 5 #define ADV_ACTIVE_SCAN_DURATION 15 @@ -79,17 +86,9 @@ bool ps_requirement_added = false; // TODO: Confirm that this value works for size and timing #define WFX_QUEUE_SIZE 10 -extern "C" { -#include "sl_net.h" -#include "sl_si91x_host_interface.h" -#include "sl_wifi.h" -#include "sl_wifi_callback_framework.h" -#include "wfx_host_events.h" -#if SL_MBEDTLS_USE_TINYCRYPT -#include "sl_si91x_constants.h" -#include "sl_si91x_trng.h" -#endif // SL_MBEDTLS_USE_TINYCRYPT -} + +// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else. +#define WIFI_SCAN_TIMEOUT_TICK 10000 WfxRsi_t wfx_rsi; @@ -109,20 +108,9 @@ bool is_wifi_disconnection_event = false; uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS; volatile bool scan_results_complete = false; volatile bool bg_scan_results_complete = false; - -// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else. -#define WIFI_SCAN_TIMEOUT_TICK 10000 - extern osSemaphoreId_t sl_rs_ble_init_sem; - -/* - * This file implements the interface to the wifi sdk - */ - static wfx_wifi_scan_ext_t temp_reset; - volatile sl_status_t callback_status = SL_STATUS_OK; - // Scan semaphore static osSemaphoreId_t sScanSemaphore; // DHCP Poll timer @@ -319,28 +307,6 @@ void sl_si91x_invoke_btn_press_event() } #endif // ENABLE_CHIP_SHELL } - -/****************************************************************** - * @fn sl_app_sleep_ready() - * @brief - * Called from the supress ticks from tickless to check if it - * is ok to go to sleep - * @param[in] None - * @return - * None - *********************************************************************/ -uint32_t sl_app_sleep_ready() -{ - if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY) - { -#if DISPLAY_ENABLED - // Powering down the LCD - sl_memlcd_power_on(NULL, false); -#endif /* DISPLAY_ENABLED */ - return true; - } - return false; -} #endif // SLI_SI91X_MCU_INTERFACE /****************************************************************** @@ -370,14 +336,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_ ChipLogError(DeviceLayer, "sl_wifi_set_performance_profile failed: 0x%lx", static_cast(status)); return status; } - if (sl_si91x_wifi_state == HIGH_PERFORMANCE) - { - wfx_rsi.dev_state &= ~(WFX_RSI_ST_SLEEP_READY); - } - else - { - wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY; - } + return status; } #endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ diff --git a/examples/platform/silabs/display/demo-ui.c b/examples/platform/silabs/display/demo-ui.c index 479af92fd5bb90..e0fe37ec9cb09b 100644 --- a/examples/platform/silabs/display/demo-ui.c +++ b/examples/platform/silabs/display/demo-ui.c @@ -25,6 +25,7 @@ #include "glib.h" #include "sl_component_catalog.h" #include "sl_memlcd.h" +#include #if SL_WIFI && !SLI_SI91X_MCU_INTERFACE #include "spi_multiplex.h" #endif // SL_WIFI && !SLI_SI91X_MCU_INTERFACE @@ -106,9 +107,12 @@ void demoUIInit(GLIB_Context_t * context) sl_status_t updateDisplay(void) { sl_status_t status = SL_STATUS_OK; -#if SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED && DISPLAY_ENABLED + +#if SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER + // In sleep, memlcd will not be retained so re-initialize MEMLCD interface after sleep wakeup sl_memlcd_post_wakeup_init(); -#endif // SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED && DISPLAY_ENABLED +#endif // SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED && CHIP_CONFIG_ENABLE_ICD_SERVER + #if SL_LCDCTRL_MUX status = sl_wfx_host_pre_lcd_spi_transfer(); if (status != SL_STATUS_OK) @@ -123,6 +127,12 @@ sl_status_t updateDisplay(void) return status; #endif // SL_LCDCTRL_MUX +#if SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER + // MEMLCD is not a UULP component and not available in sleep so powering down before sleep and need to be re-initialized after + // sleep-wakeup + sl_memlcd_power_on(NULL, false); +#endif // SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER + return SL_STATUS_OK; } diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index a08e2a2f292de1..e4d6f51bf0ded9 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -511,9 +511,9 @@ static void wfx_rsi_save_ap_info() // translation case SME_WEP: wfx_rsi.sec.security = WFX_SEC_WEP; break; - case SME_WPA3_TRANSITION: + case SME_WPA3_PERSONAL_TRANSITION: #if WIFI_ENABLE_SECURITY_WPA3_TRANSITION - case SME_WPA3: + case SME_WPA3_PERSONAL: wfx_rsi.sec.security = WFX_SEC_WPA3; #else wfx_rsi.sec.security = WFX_SEC_WPA2; @@ -557,7 +557,7 @@ static void wfx_rsi_do_join(void) break; #if WIFI_ENABLE_SECURITY_WPA3_TRANSITION case WFX_SEC_WPA3: - connect_security_mode = RSI_WPA3_TRANSITION; + connect_security_mode = RSI_WPA3_PERSONAL_TRANSITION; break; #endif // WIFI_ENABLE_SECURITY_WPA3_TRANSITION case WFX_SEC_NONE: diff --git a/examples/platform/silabs/provision/ProvisionStorageDefault.cpp b/examples/platform/silabs/provision/ProvisionStorageDefault.cpp index 1162323cda3d51..801eb9e0b70c2e 100644 --- a/examples/platform/silabs/provision/ProvisionStorageDefault.cpp +++ b/examples/platform/silabs/provision/ProvisionStorageDefault.cpp @@ -90,7 +90,7 @@ size_t RoundNearest(size_t n, size_t multiple) CHIP_ERROR WriteFile(Storage & store, SilabsConfig::Key offset_key, SilabsConfig::Key size_key, const ByteSpan & value) { uint32_t base_addr = 0; - ReturnErrorOnFailure(store.GetBaseAddress(base_addr)); + ReturnErrorOnFailure(store.GetCredentialsBaseAddress(base_addr)); if (0 == sCredentialsOffset) { ReturnErrorOnFailure(ErasePage(base_addr)); @@ -120,7 +120,7 @@ CHIP_ERROR WriteFile(Storage & store, SilabsConfig::Key offset_key, SilabsConfig CHIP_ERROR ReadFileByOffset(Storage & store, const char * description, uint32_t offset, uint32_t size, MutableByteSpan & value) { uint32_t base_addr = 0; - ReturnErrorOnFailure(store.GetBaseAddress(base_addr)); + ReturnErrorOnFailure(store.GetCredentialsBaseAddress(base_addr)); uint8_t * address = (uint8_t *) (base_addr + offset); ByteSpan span(address, size); @@ -167,12 +167,7 @@ CHIP_ERROR Storage::Initialize(uint32_t flash_addr, uint32_t flash_size) setNvm3End(base_addr); #endif } - return SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_Creds_Base_Addr, base_addr); -} - -CHIP_ERROR Storage::GetBaseAddress(uint32_t & value) -{ - return SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_Creds_Base_Addr, value); + return SetCredentialsBaseAddress(base_addr); } CHIP_ERROR Storage::Commit() @@ -625,6 +620,16 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab // Other // +CHIP_ERROR Storage::SetCredentialsBaseAddress(uint32_t addr) +{ + return SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_Creds_Base_Addr, addr); +} + +CHIP_ERROR Storage::GetCredentialsBaseAddress(uint32_t & addr) +{ + return SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_Creds_Base_Addr, addr); +} + CHIP_ERROR Storage::SetProvisionVersion(const char * value, size_t size) { return SilabsConfig::WriteConfigValueStr(SilabsConfig::kConfigKey_Provision_Version, value, size); diff --git a/examples/platform/silabs/provision/ProvisionStorageFlash.cpp b/examples/platform/silabs/provision/ProvisionStorageFlash.cpp index 35a32d6af8f5ec..af59d6560cd0fc 100644 --- a/examples/platform/silabs/provision/ProvisionStorageFlash.cpp +++ b/examples/platform/silabs/provision/ProvisionStorageFlash.cpp @@ -296,12 +296,6 @@ CHIP_ERROR Storage::Commit() return CHIP_NO_ERROR; } -CHIP_ERROR Storage::GetBaseAddress(uint32_t & value) -{ - value = (uint32_t) Flash::sReadOnlyPage; - return CHIP_NO_ERROR; -} - // // DeviceInstanceInfoProvider // @@ -675,6 +669,18 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab // Other // +CHIP_ERROR Storage::SetCredentialsBaseAddress(uint32_t addr) +{ + Flash::sReadOnlyPage = (uint8_t *) addr; + return CHIP_NO_ERROR; +} + +CHIP_ERROR Storage::GetCredentialsBaseAddress(uint32_t & addr) +{ + addr = (uint32_t) Flash::sReadOnlyPage; + return CHIP_NO_ERROR; +} + CHIP_ERROR Storage::SetProvisionVersion(const char * value, size_t size) { return Flash::Set(Parameters::ID::kVersion, value, size); diff --git a/examples/platform/silabs/wfx_rsi.h b/examples/platform/silabs/wfx_rsi.h index c47a4ee0af251e..c559e1e7610880 100644 --- a/examples/platform/silabs/wfx_rsi.h +++ b/examples/platform/silabs/wfx_rsi.h @@ -62,7 +62,6 @@ typedef enum WFX_RSI_ST_STA_READY = (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE), WFX_RSI_ST_STARTED = (1 << 9), /* RSI task started */ WFX_RSI_ST_SCANSTARTED = (1 << 10), /* Scan Started */ - WFX_RSI_ST_SLEEP_READY = (1 << 11) /* Notify the M4 to go to sleep*/ } WfxStateType_e; typedef struct WfxEvent_s diff --git a/examples/thermostat/linux/include/thermostat-delegate-impl.h b/examples/thermostat/linux/include/thermostat-delegate-impl.h index 8252f2274f9d79..6bf9d02cea462f 100644 --- a/examples/thermostat/linux/include/thermostat-delegate-impl.h +++ b/examples/thermostat/linux/include/thermostat-delegate-impl.h @@ -54,7 +54,7 @@ class ThermostatDelegate : public Delegate CHIP_ERROR GetPresetAtIndex(size_t index, PresetStructWithOwnedMembers & preset) override; - CHIP_ERROR GetActivePresetHandle(MutableByteSpan & activePresetHandle) override; + CHIP_ERROR GetActivePresetHandle(DataModel::Nullable & activePresetHandle) override; CHIP_ERROR SetActivePresetHandle(const DataModel::Nullable & newActivePresetHandle) override; diff --git a/examples/thermostat/linux/thermostat-delegate-impl.cpp b/examples/thermostat/linux/thermostat-delegate-impl.cpp index c39a757a8b0644..b931db20b7c4f7 100644 --- a/examples/thermostat/linux/thermostat-delegate-impl.cpp +++ b/examples/thermostat/linux/thermostat-delegate-impl.cpp @@ -117,9 +117,19 @@ CHIP_ERROR ThermostatDelegate::GetPresetAtIndex(size_t index, PresetStructWithOw return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } -CHIP_ERROR ThermostatDelegate::GetActivePresetHandle(MutableByteSpan & activePresetHandle) +CHIP_ERROR ThermostatDelegate::GetActivePresetHandle(DataModel::Nullable & activePresetHandle) { - return CopySpanToMutableSpan(ByteSpan(mActivePresetHandleData, mActivePresetHandleDataSize), activePresetHandle); + if (mActivePresetHandleDataSize != 0) + { + ReturnErrorOnFailure( + CopySpanToMutableSpan(ByteSpan(mActivePresetHandleData, mActivePresetHandleDataSize), activePresetHandle.Value())); + activePresetHandle.Value().reduce_size(mActivePresetHandleDataSize); + } + else + { + activePresetHandle.SetNull(); + } + return CHIP_NO_ERROR; } CHIP_ERROR ThermostatDelegate::SetActivePresetHandle(const DataModel::Nullable & newActivePresetHandle) diff --git a/examples/thermostat/nxp/zap/thermostat_matter_thread.matter b/examples/thermostat/nxp/zap/thermostat_matter_thread.matter index 001e1b43ace09d..cbe6a6280d8ec4 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_thread.matter +++ b/examples/thermostat/nxp/zap/thermostat_matter_thread.matter @@ -2530,7 +2530,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter b/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter index 066afc85509947..cd9ddc362e36ce 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter +++ b/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter @@ -2441,7 +2441,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter b/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter index 31e5775d88148f..548db02c520b9a 100644 --- a/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter +++ b/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter @@ -2138,7 +2138,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index c53651c537894e..a66c2dfdad68ba 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -2318,7 +2318,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/tv-casting-app/android/App/app/build.gradle b/examples/tv-casting-app/android/App/app/build.gradle index 3dcdad715e6393..757e6a6522f5da 100644 --- a/examples/tv-casting-app/android/App/app/build.gradle +++ b/examples/tv-casting-app/android/App/app/build.gradle @@ -7,7 +7,7 @@ android { defaultConfig { applicationId "com.chip.casting" - minSdk 24 + minSdk 26 targetSdk 30 versionCode 1 versionName "1.0" @@ -47,6 +47,8 @@ android { java.srcDirs = [ 'src/main/java', 'src/main/jni', + 'src/compat/java', + 'src/compat/jni', ] // uncomment this code to debug diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CastingContext.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CastingContext.java similarity index 87% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CastingContext.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CastingContext.java index acab829034bd56..b089e92b8faf0f 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CastingContext.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CastingContext.java @@ -5,6 +5,8 @@ import androidx.fragment.app.FragmentActivity; import com.R; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class CastingContext { private FragmentActivity fragmentActivity; diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CertTestFragment.java similarity index 97% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CertTestFragment.java index 7ee9fa3c46a0ae..27f00aab8e9325 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CertTestFragment.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CertTestFragment.java @@ -313,7 +313,17 @@ private void runCertTests(Activity activity) { "messages_presentMessages", successFailureCallback, () -> { - tvCastingApp.messages_presentMessages(kTVApp, "CastingAppTestMessage", callback); + final byte[] messageID = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5}; + tvCastingApp.messages_presentMessages( + kTVApp, + messageID, + 0, + 0, + (long) 0, + (long) 60 * 1000, + "CastingAppTestMessage", + Optional.empty(), + callback); }); runAndWait( diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CommissionerDiscoveryFragment.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CommissionerDiscoveryFragment.java similarity index 98% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CommissionerDiscoveryFragment.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CommissionerDiscoveryFragment.java index 3a119940b64839..c7aa931d9f00a1 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/CommissionerDiscoveryFragment.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/CommissionerDiscoveryFragment.java @@ -28,7 +28,11 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -/** A {@link Fragment} to discover commissioners on the network */ +/** + * @deprecated Refer to com.matter.casting.DiscoveryExampleFragment. + *

A {@link Fragment} to discover commissioners on the network + */ +@Deprecated public class CommissionerDiscoveryFragment extends Fragment { private static final String TAG = CommissionerDiscoveryFragment.class.getSimpleName(); private static final long DISCOVERY_POLL_INTERVAL_MS = 15000; diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ConnectionFragment.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/ConnectionFragment.java similarity index 96% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ConnectionFragment.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/ConnectionFragment.java index 09ba31b2c8776c..dcd681d7cbc70d 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ConnectionFragment.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/ConnectionFragment.java @@ -21,9 +21,14 @@ import com.chip.casting.util.GlobalCastingConstants; import java.util.concurrent.Executors; -/** A {@link Fragment} to get the TV Casting App commissioned / connected. */ +/** + * @deprecated Refer to com.matter.casting.ConnectionExampleFragment. + *

A {@link Fragment} to get the TV Casting App commissioned / connected + */ +@Deprecated public class ConnectionFragment extends Fragment { private static final String TAG = ConnectionFragment.class.getSimpleName(); + private static final Integer targetContentAppVendorId = 65521; private final TvCastingApp tvCastingApp; private final DiscoveredNodeData selectedCommissioner; @@ -189,7 +194,8 @@ public void handle(MatterError error) { + " port: " + selectedCommissioner.getPort()); - this.sendUdcSuccess = tvCastingApp.sendCommissioningRequest(selectedCommissioner); + this.sendUdcSuccess = + tvCastingApp.sendCommissioningRequest(selectedCommissioner, targetContentAppVendorId); updateUiOnConnectionSuccess(); } } else { diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ContentLauncherFragment.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/ContentLauncherFragment.java similarity index 94% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ContentLauncherFragment.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/ContentLauncherFragment.java index d1c3c9f957f394..14bcfcae1568f8 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ContentLauncherFragment.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/ContentLauncherFragment.java @@ -15,7 +15,11 @@ import com.chip.casting.MatterError; import com.chip.casting.TvCastingApp; -/** A {@link Fragment} to send Content Launcher commands from the TV Casting App. */ +/** + * @deprecated Refer to com.matter.casting.ContentLauncherLaunchURLExampleFragment. + *

A {@link Fragment} to send Content Launcher commands from the TV Casting App. + */ +@Deprecated public class ContentLauncherFragment extends Fragment { private static final String TAG = ContentLauncherFragment.class.getSimpleName(); diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MediaPlaybackFragment.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/MediaPlaybackFragment.java similarity index 97% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MediaPlaybackFragment.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/MediaPlaybackFragment.java index a9c38443a7d91e..b48dcd277122a4 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MediaPlaybackFragment.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/MediaPlaybackFragment.java @@ -18,7 +18,11 @@ import com.chip.casting.SuccessCallback; import com.chip.casting.TvCastingApp; -/** A {@link Fragment} for the Media Playback cluster */ +/** + * @deprecated Refer to com.matter.casting.MediaPlaybackSubscribeToCurrentStateExampleFragment. + *

A {@link Fragment} for the Media Playback cluster + */ +@Deprecated public class MediaPlaybackFragment extends Fragment { private static final String TAG = MediaPlaybackFragment.class.getSimpleName(); diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/SelectClusterFragment.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/SelectClusterFragment.java similarity index 95% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/SelectClusterFragment.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/SelectClusterFragment.java index f89fc36009e404..47cc4728f96cfb 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/SelectClusterFragment.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/app/SelectClusterFragment.java @@ -10,7 +10,11 @@ import com.R; import com.chip.casting.TvCastingApp; -/** An interstitial {@link Fragment} to select one of the supported media actions to perform */ +/** + * @deprecated Refer to com.matter.casting.ActionSelectorFragment. + *

An interstitial {@link Fragment} to select one of the supported media actions to perform + */ +@Deprecated public class SelectClusterFragment extends Fragment { private static final String TAG = SelectClusterFragment.class.getSimpleName(); diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/DACProviderStub.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/util/DACProviderStub.java similarity index 98% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/DACProviderStub.java rename to examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/util/DACProviderStub.java index 9dbae27c6e5982..2a91c055dcb47a 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/DACProviderStub.java +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/util/DACProviderStub.java @@ -11,6 +11,8 @@ import java.security.spec.ECParameterSpec; import java.security.spec.ECPrivateKeySpec; +/** @deprecated Refer to com.matter.casting.DACProviderStub. */ +@Deprecated public class DACProviderStub implements DACProvider { private String kDevelopmentDAC_Cert_FFF1_8001 = diff --git a/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/util/GlobalCastingConstants.java b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/util/GlobalCastingConstants.java new file mode 100644 index 00000000000000..526bbb07401845 --- /dev/null +++ b/examples/tv-casting-app/android/App/app/src/compat/java/com/chip/casting/util/GlobalCastingConstants.java @@ -0,0 +1,11 @@ +package com.chip.casting.util; + +public class GlobalCastingConstants { + public static final int CommissioningWindowDurationSecs = 3 * 60; + public static final int SetupPasscode = 20202021; + public static final int Discriminator = 0xF00; + + // set to true, to demo the simplified casting APIs. + // Otherwise, the deprecated casting APIs are invoked + public static final boolean ChipCastingSimplified = true; +} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/AppParameters.java similarity index 97% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/AppParameters.java index 18c9a351f0e41a..3d72b38f72eb84 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/AppParameters.java @@ -22,6 +22,8 @@ import java.math.BigInteger; import java.util.Arrays; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class AppParameters { private static final String TAG = AppParameters.class.getSimpleName(); public static final int MIN_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH = 16; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/CommissioningCallbacks.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/CommissioningCallbacks.java similarity index 97% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/CommissioningCallbacks.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/CommissioningCallbacks.java index 9a44aba792f18b..20599a4f07352a 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/CommissioningCallbacks.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/CommissioningCallbacks.java @@ -17,6 +17,8 @@ */ package com.chip.casting; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class CommissioningCallbacks { /** * This is called when the PBKDFParamRequest is received and indicates the start of the session diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/ContentApp.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/ContentApp.java similarity index 51% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/ContentApp.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/ContentApp.java index 80efc22ef52024..1c20a40b66251a 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/ContentApp.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/ContentApp.java @@ -17,10 +17,16 @@ */ package com.chip.casting; +import chip.devicecontroller.ChipClusters; +import com.matter.casting.core.Endpoint; +import java.util.ArrayList; import java.util.List; import java.util.Objects; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class ContentApp { + private Endpoint endpoint; private short endpointId; private List clusterIds; @@ -32,6 +38,33 @@ public ContentApp(short endpointId, List clusterIds) { this.isInitialized = true; } + ContentApp(Endpoint endpoint) { + this.endpoint = endpoint; + this.endpointId = (short) endpoint.getId(); + this.clusterIds = new ArrayList<>(); + if (endpoint.getCluster(ChipClusters.ApplicationBasicCluster.class) != null) { + this.clusterIds.add((int) ChipClusters.ApplicationBasicCluster.CLUSTER_ID); + } + if (endpoint.getCluster(ChipClusters.ApplicationLauncherCluster.class) != null) { + this.clusterIds.add((int) ChipClusters.ApplicationLauncherCluster.CLUSTER_ID); + } + if (endpoint.getCluster(ChipClusters.ContentLauncherCluster.class) != null) { + this.clusterIds.add((int) ChipClusters.ContentLauncherCluster.CLUSTER_ID); + } + if (endpoint.getCluster(ChipClusters.KeypadInputCluster.class) != null) { + this.clusterIds.add((int) ChipClusters.KeypadInputCluster.CLUSTER_ID); + } + if (endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) != null) { + this.clusterIds.add((int) ChipClusters.MediaPlaybackCluster.CLUSTER_ID); + } + if (endpoint.getCluster(ChipClusters.OnOffCluster.class) != null) { + this.clusterIds.add((int) ChipClusters.OnOffCluster.CLUSTER_ID); + } + if (endpoint.getCluster(ChipClusters.TargetNavigatorCluster.class) != null) { + this.clusterIds.add((int) ChipClusters.TargetNavigatorCluster.CLUSTER_ID); + } + } + public boolean equals(Object object) { if (this == object) return true; if (object == null || getClass() != object.getClass()) return false; @@ -49,6 +82,10 @@ public java.lang.String toString() { return "endpointId=" + endpointId; } + Endpoint getEndpoint() { + return endpoint; + } + public short getEndpointId() { return endpointId; } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/ContentLauncherTypes.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/ContentLauncherTypes.java similarity index 96% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/ContentLauncherTypes.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/ContentLauncherTypes.java index bc4ee6a6a24bdf..b6d7c3402989d9 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/ContentLauncherTypes.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/ContentLauncherTypes.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.Optional; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class ContentLauncherTypes { public static class AdditionalInfo { public String name; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProvider.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/DACProvider.java similarity index 92% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProvider.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/DACProvider.java index c49d73ab98c86e..7c6ac281e61568 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProvider.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/DACProvider.java @@ -17,6 +17,8 @@ */ package com.chip.casting; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public interface DACProvider { byte[] GetCertificationDeclaration(); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DiscoveredNodeData.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/DiscoveredNodeData.java similarity index 88% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DiscoveredNodeData.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/DiscoveredNodeData.java index a66d48a57c0e2a..39b9113c94a836 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DiscoveredNodeData.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/DiscoveredNodeData.java @@ -19,6 +19,7 @@ import android.net.nsd.NsdServiceInfo; import android.util.Log; +import com.matter.casting.core.CastingPlayer; import java.net.InetAddress; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -26,15 +27,18 @@ import java.util.Map; import java.util.Objects; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class DiscoveredNodeData { private static final String TAG = DiscoveredNodeData.class.getSimpleName(); - private static final int MAX_IP_ADDRESSES = 5; private static final int MAX_ROTATING_ID_LEN = 50; private static final String KEY_DEVICE_NAME = "DN"; private static final String KEY_DEVICE_TYPE = "DT"; private static final String KEY_VENDOR_PRODUCT = "VP"; + private CastingPlayer castingPlayer; + private String hostName; private String instanceName; private long longDiscriminator; @@ -119,10 +123,30 @@ public DiscoveredNodeData(VideoPlayer player) { this.port = player.getPort(); } + DiscoveredNodeData(CastingPlayer castingPlayer) { + this.castingPlayer = castingPlayer; + this.deviceName = castingPlayer.getDeviceName(); + this.ipAddresses = castingPlayer.getIpAddresses(); + this.numIPs = + castingPlayer.getIpAddresses() != null ? castingPlayer.getIpAddresses().size() : 0; + this.deviceType = castingPlayer.getDeviceType(); + this.hostName = castingPlayer.getHostName(); + this.vendorId = castingPlayer.getVendorId(); + this.productId = castingPlayer.getProductId(); + this.instanceName = castingPlayer.getInstanceName(); + if (castingPlayer.isConnected()) { + this.connectableVideoPlayer = new VideoPlayer(castingPlayer); + } + } + void setConnectableVideoPlayer(VideoPlayer videoPlayer) { this.connectableVideoPlayer = videoPlayer; } + CastingPlayer getCastingPlayer() { + return castingPlayer; + } + public boolean isPreCommissioned() { return connectableVideoPlayer != null; } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/FailureCallback.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/FailureCallback.java similarity index 85% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/FailureCallback.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/FailureCallback.java index 2ad3b9fc7222fe..5e07e9d526b1c4 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/FailureCallback.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/FailureCallback.java @@ -19,14 +19,16 @@ import android.util.Log; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public abstract class FailureCallback { private static final String TAG = FailureCallback.class.getSimpleName(); public abstract void handle(MatterError err); - protected final void handleInternal(int errorCode, String errorMessage) { + protected final void handleInternal(MatterError err) { try { - handle(new MatterError(errorCode, errorMessage)); + handle(err); } catch (Throwable t) { Log.e(TAG, "FailureCallback::Caught an unhandled Throwable from the client: " + t); } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MatterCallbackHandler.java similarity index 85% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MatterCallbackHandler.java index 493635beb692f1..7f1efd056e2e23 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MatterCallbackHandler.java @@ -19,14 +19,16 @@ import android.util.Log; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public abstract class MatterCallbackHandler { private static final String TAG = MatterCallbackHandler.class.getSimpleName(); public abstract void handle(MatterError err); - protected final void handleInternal(int errorCode, String errorMessage) { + protected final void handleInternal(MatterError err) { try { - handle(new MatterError(errorCode, errorMessage)); + handle(err); } catch (Throwable t) { Log.e(TAG, "MatterCallbackHandler::Caught an unhandled Throwable from the client: " + t); } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterError.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MatterError.java similarity index 84% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterError.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MatterError.java index ac12eaccd28977..e281bdd8b63735 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterError.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MatterError.java @@ -19,6 +19,8 @@ import java.util.Objects; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class MatterError { private long errorCode; private String errorMessage; @@ -26,8 +28,15 @@ public class MatterError { public static final MatterError DISCOVERY_SERVICE_LOST = new MatterError(4L, "Discovery service was lost."); + public static final MatterError MATTER_INTERNAL_ERROR = new MatterError(0xac, "Internal error."); + public static final MatterError NO_ERROR = new MatterError(0, null); + MatterError(com.matter.casting.support.MatterError err) { + this.errorCode = err.getErrorCode(); + this.errorMessage = err.getErrorMessage(); + } + public MatterError(long errorCode, String errorMessage) { this.errorCode = errorCode; this.errorMessage = errorMessage; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MediaPlaybackTypes.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MediaPlaybackTypes.java similarity index 93% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MediaPlaybackTypes.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MediaPlaybackTypes.java index 7bf37b5d1cd8e4..fc01b02dea23da 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MediaPlaybackTypes.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/MediaPlaybackTypes.java @@ -17,6 +17,8 @@ */ package com.chip.casting; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class MediaPlaybackTypes { public enum PlaybackStateEnum { Playing, diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SubscriptionEstablishedCallback.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/SubscriptionEstablishedCallback.java similarity index 91% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SubscriptionEstablishedCallback.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/SubscriptionEstablishedCallback.java index aab9dcd9306fd7..dd5eab2ec66556 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SubscriptionEstablishedCallback.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/SubscriptionEstablishedCallback.java @@ -19,6 +19,8 @@ import android.util.Log; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public abstract class SubscriptionEstablishedCallback { private static final String TAG = SubscriptionEstablishedCallback.class.getSimpleName(); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SuccessCallback.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/SuccessCallback.java similarity index 91% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SuccessCallback.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/SuccessCallback.java index b82845567d8276..d1194d46f3eef0 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SuccessCallback.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/SuccessCallback.java @@ -19,6 +19,8 @@ import android.util.Log; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public abstract class SuccessCallback { private static final String TAG = SuccessCallback.class.getSimpleName(); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TargetNavigatorTypes.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/TargetNavigatorTypes.java similarity index 93% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TargetNavigatorTypes.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/TargetNavigatorTypes.java index 88f71bb796ceaf..832101c9564fe7 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TargetNavigatorTypes.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/TargetNavigatorTypes.java @@ -17,6 +17,8 @@ */ package com.chip.casting; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class TargetNavigatorTypes { public static class TargetInfo { public Integer identifier; diff --git a/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/TvCastingApp.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/TvCastingApp.java new file mode 100644 index 00000000000000..cd965905065bee --- /dev/null +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/TvCastingApp.java @@ -0,0 +1,1327 @@ +/* + * Copyright (c) 2022 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. + * + */ +package com.chip.casting; + +import android.content.Context; +import android.util.Log; +import androidx.annotation.Nullable; +import chip.devicecontroller.ChipClusters; +import chip.devicecontroller.ChipStructs; +import com.matter.casting.core.CastingApp; +import com.matter.casting.core.CastingPlayer; +import com.matter.casting.core.CastingPlayerDiscovery; +import com.matter.casting.core.Endpoint; +import com.matter.casting.core.MatterCastingPlayerDiscovery; +import com.matter.casting.support.AppParameters; +import com.matter.casting.support.CommissionableData; +import com.matter.casting.support.ConnectionCallbacks; +import com.matter.casting.support.DACProvider; +import com.matter.casting.support.IdentificationDeclarationOptions; +import com.matter.casting.support.MatterCallback; +import com.matter.casting.support.MatterError; +import com.matter.casting.support.TargetAppInfo; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated +public class TvCastingApp { + private static final String TAG = TvCastingApp.class.getSimpleName(); + + private com.chip.casting.AppParameters appParametersCompat; + private int commissioningWindowTimeout; + private CommissioningCallbacks commissioningCallbacks; + private SuccessCallback onConnectionSuccess; + private FailureCallback onConnectionFailure; + private SuccessCallback onNewOrUpdatedEndpointCallback; + private CastingPlayer targetCastingPlayer; + + private abstract class CastingPlayerChangeListenerAdapter + extends CastingPlayerDiscovery.CastingPlayerChangeListener { + public abstract void initialize(SuccessCallback discoverySuccessCallback); + } + + private CastingPlayerChangeListenerAdapter castingPlayerDiscoveryChangeListener = + new CastingPlayerChangeListenerAdapter() { + private SuccessCallback discoverySuccessCallbackCompat; + + @Override + public void initialize(SuccessCallback discoverySuccessCallback) { + this.discoverySuccessCallbackCompat = discoverySuccessCallback; + } + + @Override + public void onAdded(CastingPlayer castingPlayer) { + if (discoverySuccessCallbackCompat == null) { + Log.e(TAG, "discoverySuccessCallbackCompat not set"); + return; + } + discoverySuccessCallbackCompat.handleInternal(new DiscoveredNodeData((castingPlayer))); + } + + @Override + public void onChanged(CastingPlayer castingPlayer) { + if (discoverySuccessCallbackCompat == null) { + Log.e(TAG, "discoverySuccessCallbackCompat not set"); + return; + } + discoverySuccessCallbackCompat.handleInternal(new DiscoveredNodeData((castingPlayer))); + } + + @Override + public void onRemoved(CastingPlayer castingPlayer) { + Log.e(TAG, "CastingPlayerChangeListener.onRemoved() not implemented"); + } + }; + + private interface DACProviderAdapter extends DACProvider { + void initialize(com.chip.casting.DACProvider dacProviderCompat); + } + + private DACProviderAdapter dacProvider = + new DACProviderAdapter() { + private com.chip.casting.DACProvider dacProviderCompat; + + public void initialize(com.chip.casting.DACProvider dacProviderCompat) { + this.dacProviderCompat = dacProviderCompat; + } + + @Override + public byte[] GetCertificationDeclaration() { + if (dacProviderCompat == null) { + Log.e(TAG, "dacProviderCompat not set"); + return null; + } + return dacProviderCompat.GetCertificationDeclaration(); + } + + @Override + public byte[] GetFirmwareInformation() { + if (dacProviderCompat == null) { + Log.e(TAG, "dacProviderCompat not set"); + return null; + } + return dacProviderCompat.GetFirmwareInformation(); + } + + @Override + public byte[] GetDeviceAttestationCert() { + if (dacProviderCompat == null) { + Log.e(TAG, "dacProviderCompat not set"); + return null; + } + return dacProviderCompat.GetDeviceAttestationCert(); + } + + @Override + public byte[] GetProductAttestationIntermediateCert() { + if (dacProviderCompat == null) { + Log.e(TAG, "dacProviderCompat not set"); + return null; + } + return dacProviderCompat.GetProductAttestationIntermediateCert(); + } + + @Override + public byte[] SignWithDeviceAttestationKey(byte[] message) { + if (dacProviderCompat == null) { + Log.e(TAG, "dacProviderCompat not set"); + return null; + } + return dacProviderCompat.SignWithDeviceAttestationKey(message); + } + }; + + private static final List DISCOVERY_TARGET_DEVICE_TYPE_FILTER = + Arrays.asList(35L); // Matter Casting Video player = 35; + + private static TvCastingApp sInstance; + + private TvCastingApp() {} + + public static TvCastingApp getInstance() { + if (sInstance == null) { + sInstance = new TvCastingApp(); + } + return sInstance; + } + + public boolean initApp( + Context applicationContext, com.chip.casting.AppParameters appParametersCompat) { + if (applicationContext == null + || appParametersCompat == null + || appParametersCompat.getConfigurationManager() == null) { + return false; + } + + this.appParametersCompat = appParametersCompat; + + AppParameters appParameters = + new AppParameters( + applicationContext, + () -> appParametersCompat.getConfigurationManager(), + () -> appParametersCompat.getRotatingDeviceIdUniqueId(), + () -> { + CommissionableData commissionableData = + new CommissionableData( + appParametersCompat.getSetupPasscode(), + appParametersCompat.getDiscriminator()); + commissionableData.setSpake2pIterationCount( + appParametersCompat.getSpake2pIterationCount()); + commissionableData.setSpake2pSaltBase64(appParametersCompat.getSpake2pSaltBase64()); + commissionableData.setSpake2pVerifierBase64( + appParametersCompat.getSpake2pVerifierBase64()); + return commissionableData; + }, + this.dacProvider); + + // Initialize the SDK using the appParameters and check if it returns successfully + MatterError err = CastingApp.getInstance().initialize(appParameters); + if (err.hasError()) { + Log.e(TAG, "Failed to initialize Matter CastingApp. Err: " + err); + return false; + } + + err = CastingApp.getInstance().start(); + if (err.hasError()) { + Log.e(TAG, "Failed to start Matter CastingApp. Err: " + err); + return false; + } + return true; + } + + public void setDACProvider(com.chip.casting.DACProvider dacProviderCompat) { + this.dacProvider.initialize(dacProviderCompat); + } + + public void discoverVideoPlayerCommissioners( + SuccessCallback discoverySuccessCallback, + FailureCallback discoveryFailureCallback) { + + // stop before starting another discovery session + stopVideoPlayerDiscovery(); + + castingPlayerDiscoveryChangeListener.initialize(discoverySuccessCallback); + MatterError err = + MatterCastingPlayerDiscovery.getInstance() + .addCastingPlayerChangeListener(castingPlayerDiscoveryChangeListener); + if (err.hasError()) { + Log.e(TAG, "addCastingPlayerChangeListener before starting discovery failed. Err: " + err); + discoveryFailureCallback.handleInternal(new com.chip.casting.MatterError(err)); + return; + } + + err = + MatterCastingPlayerDiscovery.getInstance() + .startDiscovery(DISCOVERY_TARGET_DEVICE_TYPE_FILTER.get(0)); + if (err.hasError()) { + Log.e(TAG, "startDiscovery failed. Err: " + err); + discoveryFailureCallback.handleInternal(new com.chip.casting.MatterError(err)); + } + } + + public void stopVideoPlayerDiscovery() { + MatterError err = MatterCastingPlayerDiscovery.getInstance().stopDiscovery(); + if (err.hasError()) { + Log.e(TAG, "stopDiscovery failed. Err: " + err); + return; + } + + err = + MatterCastingPlayerDiscovery.getInstance() + .removeCastingPlayerChangeListener(castingPlayerDiscoveryChangeListener); + if (err.hasError()) { + Log.e(TAG, "removeCastingPlayerChangeListener failed. Err: " + err); + } + } + + public boolean openBasicCommissioningWindow( + int commissioningWindowTimeout, + CommissioningCallbacks commissioningCallbacks, + SuccessCallback onConnectionSuccess, + FailureCallback onConnectionFailure, + SuccessCallback onNewOrUpdatedEndpointCallback) { + this.commissioningWindowTimeout = commissioningWindowTimeout; + this.commissioningCallbacks = commissioningCallbacks; + this.onConnectionSuccess = onConnectionSuccess; + this.onConnectionFailure = onConnectionFailure; + this.onNewOrUpdatedEndpointCallback = onNewOrUpdatedEndpointCallback; + return true; + } + + public boolean sendCommissioningRequest(DiscoveredNodeData commissioner, Integer vendorId) { + if (commissioningCallbacks == null + || onConnectionSuccess == null + || onConnectionFailure == null + || onNewOrUpdatedEndpointCallback == null) { + Log.e(TAG, "Commissioning/connection callbacks not set"); + return false; + } + + this.targetCastingPlayer = commissioner.getCastingPlayer(); + + IdentificationDeclarationOptions idOptions = new IdentificationDeclarationOptions(); + idOptions.addTargetAppInfo(new TargetAppInfo(vendorId, null)); + + MatterError err = + targetCastingPlayer.verifyOrEstablishConnection( + new ConnectionCallbacks( + new MatterCallback() { + @Override + public void handle(Void response) { + ((MatterCallbackHandler) commissioningCallbacks.getCommissioningComplete()) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + onConnectionSuccess.handleInternal(new VideoPlayer(targetCastingPlayer)); + + List endpoints = targetCastingPlayer.getEndpoints(); + if (endpoints != null) { + for (Endpoint endpoint : endpoints) { + onNewOrUpdatedEndpointCallback.handleInternal(new ContentApp(endpoint)); + } + } + } + }, + new MatterCallback() { + @Override + public void handle(MatterError err) { + onConnectionFailure.handleInternal(new com.chip.casting.MatterError(err)); + } + }, + null), + (short) this.commissioningWindowTimeout, + idOptions); + + if (err.hasError()) { + Log.e( + TAG, "sendCommissioningRequest failed to call verifyOrEstablishConnection. Err: " + err); + return false; + } + + return true; + } + + public boolean verifyOrEstablishConnection( + VideoPlayer targetVideoPlayer, + SuccessCallback onConnectionSuccess, + FailureCallback onConnectionFailure, + SuccessCallback onNewOrUpdatedEndpointCallback) { + Log.e(TAG, "verifyOrEstablishConnection is unsupported"); + return false; + } + + public void shutdownAllSubscriptions() { + MatterError err = CastingApp.getInstance().shutdownAllSubscriptions(); + if (err.hasError()) { + Log.e(TAG, "shutdownAllSubscriptions failed. Err: " + err); + } + } + + public void disconnect() { + if (targetCastingPlayer != null) { + targetCastingPlayer.disconnect(); + } + } + + public boolean purgeCache() { + MatterError err = CastingApp.getInstance().clearCache(); + if (err.hasError()) { + Log.e(TAG, "purgeCache failed. Err: " + err); + return false; + } + return true; + } + + private Endpoint getTargetEndpoint(ContentApp contentApp) { + if (targetCastingPlayer == null || targetCastingPlayer.getEndpoints() == null) { + return null; + } + + for (Endpoint endpoint : targetCastingPlayer.getEndpoints()) { + if (endpoint.getId() == contentApp.getEndpointId()) { + return endpoint; + } + } + + return null; + } + + public boolean contentLauncherLaunchURL( + ContentApp contentApp, String contentUrl, String contentDisplayStr, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ContentLauncherCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.ContentLauncherCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.launchURL( + new ChipClusters.ContentLauncherCluster.LauncherResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "LauncherResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + contentUrl, + Optional.of(contentDisplayStr), + Optional.empty()); + + return true; + } + + public boolean contentLauncher_launchContent( + ContentApp contentApp, + ContentLauncherTypes.ContentSearch searchCompat, + boolean autoPlay, + String data, + Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ContentLauncherCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.ContentLauncherCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + // translate searchCompat + ArrayList parameterList = null; + if (searchCompat.parameterList != null) { + parameterList = new ArrayList<>(); + for (ContentLauncherTypes.Parameter parameterCompat : searchCompat.parameterList) { + ArrayList externalIDList = null; + if (parameterCompat.externalIDList != null && parameterCompat.externalIDList.isPresent()) { + externalIDList = new ArrayList<>(); + for (ContentLauncherTypes.AdditionalInfo additionalInfoCompat : + parameterCompat.externalIDList.get()) { + externalIDList.add( + new ChipStructs.ContentLauncherClusterAdditionalInfoStruct( + additionalInfoCompat.name, additionalInfoCompat.value)); + } + } + parameterList.add( + new ChipStructs.ContentLauncherClusterParameterStruct( + parameterCompat.type, + parameterCompat.value, + externalIDList != null ? Optional.of(externalIDList) : Optional.empty())); + } + } + ChipStructs.ContentLauncherClusterContentSearchStruct search = + new ChipStructs.ContentLauncherClusterContentSearchStruct(parameterList); + + cluster.launchContent( + new ChipClusters.ContentLauncherCluster.LauncherResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "LauncherResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + search, + autoPlay, + data != null ? Optional.of(data) : Optional.empty(), + Optional.empty(), + Optional.empty()); + return true; + } + + public boolean mediaPlayback_play(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.play( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean mediaPlayback_pause(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.pause( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean mediaPlayback_stopPlayback(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.stop( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean mediaPlayback_next(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.next( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean mediaPlayback_previous(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.previous( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean mediaPlayback_rewind(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.rewind( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + Optional.empty()); + return true; + } + + public boolean mediaPlayback_fastForward(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.fastForward( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + Optional.empty()); + return true; + } + + public boolean mediaPlayback_startOver(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.startOver( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean mediaPlayback_seek(ContentApp contentApp, long position, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.seek( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + position); + return true; + } + + public boolean mediaPlayback_skipForward( + ContentApp contentApp, long deltaPositionMilliseconds, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.skipForward( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + deltaPositionMilliseconds); + return true; + } + + public boolean mediaPlayback_skipBackward( + ContentApp contentApp, long deltaPositionMilliseconds, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.skipBackward( + new ChipClusters.MediaPlaybackCluster.PlaybackResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "PlaybackResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + deltaPositionMilliseconds); + return true; + } + + public boolean mediaPlayback_subscribeToCurrentState( + ContentApp contentApp, + SuccessCallback readSuccessHandler, + FailureCallback readFailureHandler, + int minInterval, + int maxInterval, + SubscriptionEstablishedCallback subscriptionEstablishedHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MediaPlaybackCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MediaPlaybackCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.subscribeCurrentStateAttribute( + new ChipClusters.IntegerAttributeCallback() { + @Override + public void onSuccess(int value) { + readSuccessHandler.handleInternal(MediaPlaybackTypes.PlaybackStateEnum.values()[value]); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "IntegerAttributeCallback.onError: " + error); + readFailureHandler.handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + + @Override + public void onSubscriptionEstablished(long subscriptionId) { + subscriptionEstablishedHandler.handleInternal(); + } + }, + minInterval, + maxInterval); + return true; + } + + public boolean applicationLauncher_launchApp( + ContentApp contentApp, + short catalogVendorId, + String applicationId, + byte[] data, + Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationLauncherCluster cluster = + endpoint != null + ? endpoint.getCluster(ChipClusters.ApplicationLauncherCluster.class) + : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + // translate to application + Optional application = + Optional.empty(); + if (applicationId != null) { + application = + Optional.of( + new ChipStructs.ApplicationLauncherClusterApplicationStruct( + (int) catalogVendorId, applicationId)); + } + + cluster.launchApp( + new ChipClusters.ApplicationLauncherCluster.LauncherResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "LauncherResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + application, + data != null ? Optional.of(data) : Optional.empty()); + return true; + } + + public boolean applicationLauncher_stopApp( + ContentApp contentApp, short catalogVendorId, String applicationId, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationLauncherCluster cluster = + endpoint != null + ? endpoint.getCluster(ChipClusters.ApplicationLauncherCluster.class) + : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + // translate to application + Optional application = + Optional.empty(); + if (applicationId != null) { + application = + Optional.of( + new ChipStructs.ApplicationLauncherClusterApplicationStruct( + (int) catalogVendorId, applicationId)); + } + + cluster.stopApp( + new ChipClusters.ApplicationLauncherCluster.LauncherResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "LauncherResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + application); + return true; + } + + public boolean applicationLauncher_hideApp( + ContentApp contentApp, short catalogVendorId, String applicationId, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationLauncherCluster cluster = + endpoint != null + ? endpoint.getCluster(ChipClusters.ApplicationLauncherCluster.class) + : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + // translate to application + Optional application = + Optional.empty(); + if (applicationId != null) { + application = + Optional.of( + new ChipStructs.ApplicationLauncherClusterApplicationStruct( + (int) catalogVendorId, applicationId)); + } + + cluster.hideApp( + new ChipClusters.ApplicationLauncherCluster.LauncherResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "LauncherResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + application); + return true; + } + + public boolean targetNavigator_navigateTarget( + ContentApp contentApp, byte target, String data, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.TargetNavigatorCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.TargetNavigatorCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.navigateTarget( + new ChipClusters.TargetNavigatorCluster.NavigateTargetResponseCallback() { + @Override + public void onSuccess(Integer status, Optional data) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "NavigateTargetResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + (int) target, + data != null ? Optional.of(data) : Optional.empty()); + return true; + } + + public boolean targetNavigator_subscribeToTargetList( + ContentApp contentApp, + SuccessCallback readSuccessHandler, + FailureCallback readFailureHandler, + int minInterval, + int maxInterval, + SubscriptionEstablishedCallback subscriptionEstablishedHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.TargetNavigatorCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.TargetNavigatorCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.subscribeTargetListAttribute( + new ChipClusters.TargetNavigatorCluster.TargetListAttributeCallback() { + @Override + public void onSuccess( + List targetInfoList) { + List targetInfoListCompat = null; + if (targetInfoList != null) { + targetInfoListCompat = new ArrayList<>(); + for (ChipStructs.TargetNavigatorClusterTargetInfoStruct targetInfo : targetInfoList) { + targetInfoListCompat.add( + new TargetNavigatorTypes.TargetInfo(targetInfo.identifier, targetInfo.name)); + } + } + readSuccessHandler.handleInternal(targetInfoListCompat); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "TargetListAttributeCallback.onError: " + error); + readFailureHandler.handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + + @Override + public void onSubscriptionEstablished(long subscriptionId) { + subscriptionEstablishedHandler.handleInternal(); + } + }, + minInterval, + maxInterval); + return true; + } + + public boolean keypadInput_sendKey(ContentApp contentApp, byte keyCode, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.KeypadInputCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.KeypadInputCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.sendKey( + new ChipClusters.KeypadInputCluster.SendKeyResponseCallback() { + @Override + public void onSuccess(Integer status) { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "LauncherResponseCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + (int) keyCode); + return true; + } + + public boolean applicationBasic_readVendorName( + ContentApp contentApp, + SuccessCallback readSuccessHandler, + FailureCallback readFailureHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationBasicCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.ApplicationBasicCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.readVendorNameAttribute( + new ChipClusters.CharStringAttributeCallback() { + @Override + public void onSuccess(String value) { + readSuccessHandler.handleInternal(value); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "CharStringAttributeCallback.onError: " + error); + readFailureHandler.handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean applicationBasic_readVendorID( + ContentApp contentApp, + SuccessCallback readSuccessHandler, + FailureCallback readFailureHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationBasicCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.ApplicationBasicCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.readVendorIDAttribute( + new ChipClusters.IntegerAttributeCallback() { + @Override + public void onSuccess(int value) { + readSuccessHandler.handleInternal(value); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "IntegerAttributeCallback.onError: " + error); + readFailureHandler.handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean applicationBasic_readApplicationName( + ContentApp contentApp, + SuccessCallback readSuccessHandler, + FailureCallback readFailureHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationBasicCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.ApplicationBasicCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.readApplicationNameAttribute( + new ChipClusters.CharStringAttributeCallback() { + @Override + public void onSuccess(String value) { + readSuccessHandler.handleInternal(value); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "CharStringAttributeCallback.onError: " + error); + readFailureHandler.handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean applicationBasic_readProductID( + ContentApp contentApp, + SuccessCallback readSuccessHandler, + FailureCallback readFailureHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationBasicCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.ApplicationBasicCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.readProductIDAttribute( + new ChipClusters.IntegerAttributeCallback() { + @Override + public void onSuccess(int value) { + readSuccessHandler.handleInternal(value); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "IntegerAttributeCallback.onError: " + error); + readFailureHandler.handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean applicationBasic_readApplicationVersion( + ContentApp contentApp, + SuccessCallback readSuccessHandler, + FailureCallback readFailureHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.ApplicationBasicCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.ApplicationBasicCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.readApplicationVersionAttribute( + new ChipClusters.CharStringAttributeCallback() { + @Override + public void onSuccess(String value) { + readSuccessHandler.handleInternal(value); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "CharStringAttributeCallback.onError: " + error); + readFailureHandler.handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean onOff_on(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.OnOffCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.OnOffCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.on( + new ChipClusters.DefaultClusterCallback() { + @Override + public void onSuccess() { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "DefaultClusterCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean onOff_off(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.OnOffCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.OnOffCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.off( + new ChipClusters.DefaultClusterCallback() { + @Override + public void onSuccess() { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "DefaultClusterCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean onOff_toggle(ContentApp contentApp, Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.OnOffCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.OnOffCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.toggle( + new ChipClusters.DefaultClusterCallback() { + @Override + public void onSuccess() { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "DefaultClusterCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }); + return true; + } + + public boolean messages_presentMessages( + ContentApp contentApp, + byte[] messageID, + Integer priority, + Integer messageControl, + @Nullable Long startTime, + @Nullable Long duration, + String messageText, + Optional> responses, + Object responseHandler) { + + Endpoint endpoint = getTargetEndpoint(contentApp); + ChipClusters.MessagesCluster cluster = + endpoint != null ? endpoint.getCluster(ChipClusters.MessagesCluster.class) : null; + if (cluster == null) { + Log.e(TAG, "Cluster not found"); + return false; + } + + cluster.presentMessagesRequest( + new ChipClusters.DefaultClusterCallback() { + @Override + public void onSuccess() { + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.NO_ERROR); + } + + @Override + public void onError(Exception error) { + Log.e(TAG, "DefaultClusterCallback.onError: " + error); + ((MatterCallbackHandler) responseHandler) + .handleInternal(com.chip.casting.MatterError.MATTER_INTERNAL_ERROR); + } + }, + messageID, + priority, + messageControl, + startTime, + duration, + messageText, + responses); + return true; + } +} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/VideoPlayer.java b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/VideoPlayer.java similarity index 81% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/VideoPlayer.java rename to examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/VideoPlayer.java index fab9b027a78cc4..1933e28979f8a6 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/VideoPlayer.java +++ b/examples/tv-casting-app/android/App/app/src/compat/jni/com/chip/casting/VideoPlayer.java @@ -17,15 +17,19 @@ */ package com.chip.casting; +import com.matter.casting.core.CastingPlayer; +import com.matter.casting.core.Endpoint; import java.net.InetAddress; -import java.util.HashSet; +import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.Set; +/** @deprecated Use the APIs described in /examples/tv-casting-app/APIs.md instead. */ +@Deprecated public class VideoPlayer { private static final String TAG = VideoPlayer.class.getSimpleName(); + private CastingPlayer castingPlayer; private long nodeId; private byte fabricIndex; private String deviceName; @@ -82,41 +86,25 @@ public VideoPlayer( this.isInitialized = true; } - public boolean isSameAs(DiscoveredNodeData discoveredNodeData) { - // return false because 'this' VideoPlayer is not null - if (discoveredNodeData == null) { - return false; - } - - // return true if hostNames match - if (Objects.equals(hostName, discoveredNodeData.getHostName())) { - return true; - } - - // return false because deviceNames are different - if (Objects.equals(deviceName, discoveredNodeData.getDeviceName()) == false) { - return false; - } - - // return false because not even a single IP Address matches - if (ipAddresses != null) { - boolean matchFound = false; - Set discoveredNodeDataIpAddressSet = - new HashSet(discoveredNodeData.getIpAddresses()); - for (InetAddress videoPlayerIpAddress : ipAddresses) { - if (discoveredNodeDataIpAddressSet.contains(videoPlayerIpAddress)) { - matchFound = true; - break; - } - } - - if (!matchFound) { - return false; + public VideoPlayer(CastingPlayer castingPlayer) { + this.castingPlayer = castingPlayer; + this.deviceType = (int) castingPlayer.getDeviceType(); + this.deviceName = castingPlayer.getDeviceName(); + this.hostName = castingPlayer.getHostName(); + this.ipAddresses = castingPlayer.getIpAddresses(); + this.numIPs = + castingPlayer.getIpAddresses() != null ? castingPlayer.getIpAddresses().size() : 0; + this.isConnected = castingPlayer.isConnected(); + this.productId = castingPlayer.getProductId(); + this.vendorId = castingPlayer.getVendorId(); + List endpoints = castingPlayer.getEndpoints(); + if (endpoints != null) { + this.contentApps = new ArrayList<>(); + for (Endpoint endpoint : endpoints) { + contentApps.add(new ContentApp(endpoint)); } } - - // otherwise, return true - return true; + this.isInitialized = true; } public boolean equals(Object object) { @@ -175,6 +163,10 @@ public String toString() { + '}'; } + CastingPlayer getCastingPlayer() { + return castingPlayer; + } + public long getNodeId() { return nodeId; } diff --git a/examples/tv-casting-app/android/App/app/src/main/AndroidManifest.xml b/examples/tv-casting-app/android/App/app/src/main/AndroidManifest.xml index e551de818eb5b0..b47ec80a86b0d9 100644 --- a/examples/tv-casting-app/android/App/app/src/main/AndroidManifest.xml +++ b/examples/tv-casting-app/android/App/app/src/main/AndroidManifest.xml @@ -18,9 +18,9 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:name=".chip.casting.app.ChipTvCastingApplication" + android:name=".matter.casting.ChipTvCastingApplication" android:theme="@style/Theme.CHIPTVCastingApp"> - diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/GlobalCastingConstants.java b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/GlobalCastingConstants.java deleted file mode 100644 index 483f1efedb1b46..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/GlobalCastingConstants.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.chip.casting.util; - -public class GlobalCastingConstants { - public static final String CommissionerServiceType = "_matterd._udp."; - public static final int CommissioningWindowDurationSecs = 3 * 60; - public static final int SetupPasscode = 20202021; - public static final int Discriminator = 0xF00; - public static final boolean ChipCastingSimplified = - true; // set to true, to demo the simplified casting APIs. Otherwise, the older deprecated - // APIs are invoked -} diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ChipTvCastingApplication.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ChipTvCastingApplication.java similarity index 84% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ChipTvCastingApplication.java rename to examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ChipTvCastingApplication.java index 4986cc28e49c01..bea5b88a310158 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/ChipTvCastingApplication.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ChipTvCastingApplication.java @@ -1,4 +1,4 @@ -package com.chip.casting.app; +package com.matter.casting; import android.app.Application; diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MainActivity.java similarity index 92% rename from examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java rename to examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MainActivity.java index 685dbf2fb6426e..53908322d10155 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/MainActivity.java @@ -1,4 +1,4 @@ -package com.chip.casting.app; +package com.matter.casting; import android.os.Bundle; import android.util.Log; @@ -9,15 +9,13 @@ import com.chip.casting.AppParameters; import com.chip.casting.DiscoveredNodeData; import com.chip.casting.TvCastingApp; +import com.chip.casting.app.CertTestFragment; +import com.chip.casting.app.CommissionerDiscoveryFragment; +import com.chip.casting.app.ConnectionFragment; +import com.chip.casting.app.ContentLauncherFragment; +import com.chip.casting.app.MediaPlaybackFragment; +import com.chip.casting.app.SelectClusterFragment; import com.chip.casting.util.GlobalCastingConstants; -import com.matter.casting.ActionSelectorFragment; -import com.matter.casting.ApplicationBasicReadVendorIDExampleFragment; -import com.matter.casting.ConnectionExampleFragment; -import com.matter.casting.ContentLauncherLaunchURLExampleFragment; -import com.matter.casting.DiscoveryExampleFragment; -import com.matter.casting.InitializationExample; -import com.matter.casting.MediaPlaybackSubscribeToCurrentStateExampleFragment; -import com.matter.casting.PreferencesConfigurationManager; import com.matter.casting.core.CastingPlayer; import java.util.Random; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/NsdDiscoveryListener.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/NsdDiscoveryListener.java deleted file mode 100644 index 1a9556e5fdb6d2..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/NsdDiscoveryListener.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2022 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. - * - */ -package com.chip.casting; - -import android.net.nsd.NsdManager; -import android.net.nsd.NsdServiceInfo; -import android.util.Log; -import chip.platform.NsdManagerServiceResolver; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class NsdDiscoveryListener implements NsdManager.DiscoveryListener { - private static final String TAG = NsdDiscoveryListener.class.getSimpleName(); - - private final NsdManager nsdManager; - private final String targetServiceType; - private final List deviceTypeFilter; - private final List preCommissionedVideoPlayers; - private final SuccessCallback successCallback; - private final FailureCallback failureCallback; - private final NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState; - private final ExecutorService resolutionExecutor; - - public NsdDiscoveryListener( - NsdManager nsdManager, - String targetServiceType, - List deviceTypeFilter, - List preCommissionedVideoPlayers, - SuccessCallback successCallback, - FailureCallback failureCallback, - NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState) { - this.nsdManager = nsdManager; - this.targetServiceType = targetServiceType; - this.deviceTypeFilter = deviceTypeFilter; - this.preCommissionedVideoPlayers = preCommissionedVideoPlayers; - this.successCallback = successCallback; - this.failureCallback = failureCallback; - this.nsdManagerResolverAvailState = nsdManagerResolverAvailState; - this.resolutionExecutor = Executors.newSingleThreadExecutor(); - } - - @Override - public void onDiscoveryStarted(String regType) { - Log.d(TAG, "Service discovery started. regType: " + regType); - } - - @Override - public void onServiceFound(NsdServiceInfo service) { - this.resolutionExecutor.execute( - new Runnable() { - @Override - public void run() { - Log.d(TAG, "Service discovery success. " + service); - if (service.getServiceType().equals(targetServiceType)) { - if (nsdManagerResolverAvailState != null) { - nsdManagerResolverAvailState.acquireResolver(); - } - - Log.d(TAG, "Calling NsdManager.resolveService for " + service); - nsdManager.resolveService( - service, - new NsdResolveListener( - nsdManager, - deviceTypeFilter, - preCommissionedVideoPlayers, - successCallback, - failureCallback, - nsdManagerResolverAvailState, - 1)); - } else { - Log.d(TAG, "Ignoring discovered service: " + service.toString()); - } - } - }); - } - - @Override - public void onServiceLost(NsdServiceInfo service) { - // When the network service is no longer available. - // Internal bookkeeping code goes here. - Log.e(TAG, "Service lost: " + service); - failureCallback.handle(MatterError.DISCOVERY_SERVICE_LOST); - } - - @Override - public void onDiscoveryStopped(String serviceType) { - Log.i(TAG, "Discovery stopped: " + serviceType); - if (nsdManagerResolverAvailState != null) { - nsdManagerResolverAvailState.signalFree(); - } - } - - @Override - public void onStartDiscoveryFailed(String serviceType, int errorCode) { - Log.e(TAG, "Discovery failed to start: Error code:" + errorCode); - TvCastingApp.getInstance().resetDiscoveryState(); - failureCallback.handle( - new MatterError( - 3, "NsdDiscoveryListener Discovery failed to start: Nsd Error code:" + errorCode)); - } - - @Override - public void onStopDiscoveryFailed(String serviceType, int errorCode) { - Log.e(TAG, "Discovery failed to stop: Error code:" + errorCode); - if (nsdManagerResolverAvailState != null) { - nsdManagerResolverAvailState.signalFree(); - } - failureCallback.handle( - new MatterError( - 3, "NsdDiscoveryListener Discovery failed to stop: Nsd Error code:" + errorCode)); - } -} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/NsdResolveListener.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/NsdResolveListener.java deleted file mode 100644 index 638425675dc99b..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/NsdResolveListener.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2022 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. - * - */ -package com.chip.casting; - -import android.net.nsd.NsdManager; -import android.net.nsd.NsdServiceInfo; -import android.util.Log; -import chip.platform.NsdManagerServiceResolver; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -public class NsdResolveListener implements NsdManager.ResolveListener { - - private static final String TAG = NsdResolveListener.class.getSimpleName(); - - private static final int MAX_RESOLUTION_ATTEMPTS = 5; - private static final int RESOLUTION_ATTEMPT_DELAY_SECS = 1; - - private final NsdManager nsdManager; - private final List deviceTypeFilter; - private final List preCommissionedVideoPlayers; - private final SuccessCallback successCallback; - private final FailureCallback failureCallback; - private final NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState; - private final int resolutionAttemptNumber; - - public NsdResolveListener( - NsdManager nsdManager, - List deviceTypeFilter, - List preCommissionedVideoPlayers, - SuccessCallback successCallback, - FailureCallback failureCallback, - NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState, - int resolutionAttemptNumber) { - this.nsdManager = nsdManager; - this.deviceTypeFilter = deviceTypeFilter; - this.preCommissionedVideoPlayers = preCommissionedVideoPlayers; - if (preCommissionedVideoPlayers != null) { - for (VideoPlayer videoPlayer : preCommissionedVideoPlayers) { - Log.d(TAG, "Precommissioned video player: " + videoPlayer); - } - } - this.successCallback = successCallback; - this.failureCallback = failureCallback; - this.nsdManagerResolverAvailState = nsdManagerResolverAvailState; - this.resolutionAttemptNumber = resolutionAttemptNumber; - } - - @Override - public void onServiceResolved(NsdServiceInfo serviceInfo) { - DiscoveredNodeData discoveredNodeData = new DiscoveredNodeData(serviceInfo); - Log.d(TAG, "DiscoveredNodeData resolved: " + discoveredNodeData); - - if (nsdManagerResolverAvailState != null) { - nsdManagerResolverAvailState.signalFree(); - } - - if (isPassingDeviceTypeFilter(discoveredNodeData)) { - addCommissioningInfo(discoveredNodeData); - successCallback.handle(discoveredNodeData); - } else { - Log.d( - TAG, - "DiscoveredNodeData ignored because it did not pass the device type filter " - + discoveredNodeData); - } - } - - @Override - public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) { - if (nsdManagerResolverAvailState != null) { - if (errorCode != NsdManager.FAILURE_ALREADY_ACTIVE - || resolutionAttemptNumber >= MAX_RESOLUTION_ATTEMPTS) { - nsdManagerResolverAvailState.signalFree(); - } - } - - switch (errorCode) { - case NsdManager.FAILURE_ALREADY_ACTIVE: - Log.e(TAG, "NsdResolveListener FAILURE_ALREADY_ACTIVE - Service: " + serviceInfo); - if (resolutionAttemptNumber < MAX_RESOLUTION_ATTEMPTS) { - Log.d(TAG, "NsdResolveListener Scheduling a retry to resolve service " + serviceInfo); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - nsdManager.resolveService( - serviceInfo, - new NsdResolveListener( - nsdManager, - deviceTypeFilter, - preCommissionedVideoPlayers, - successCallback, - failureCallback, - nsdManagerResolverAvailState, - resolutionAttemptNumber + 1)); - } - }, - RESOLUTION_ATTEMPT_DELAY_SECS, - TimeUnit.SECONDS); - } else { // giving up - failureCallback.handle( - new MatterError( - 3, "NsdResolveListener FAILURE_ALREADY_ACTIVE - Service: " + serviceInfo)); - } - break; - case NsdManager.FAILURE_INTERNAL_ERROR: - Log.e(TAG, "NsdResolveListener FAILURE_INTERNAL_ERROR - Service: " + serviceInfo); - failureCallback.handle( - new MatterError( - 3, "NsdResolveListener FAILURE_INTERNAL_ERROR - Service: " + serviceInfo)); - break; - case NsdManager.FAILURE_MAX_LIMIT: - Log.e(TAG, "NsdResolveListener FAILURE_MAX_LIMIT - Service: " + serviceInfo); - failureCallback.handle( - new MatterError(19, "NsdResolveListener FAILURE_MAX_LIMIT - Service: " + serviceInfo)); - break; - } - } - - private boolean isPassingDeviceTypeFilter(DiscoveredNodeData discoveredNodeData) { - return deviceTypeFilter == null - || deviceTypeFilter.isEmpty() - || deviceTypeFilter.contains(discoveredNodeData.getDeviceType()); - } - - private void addCommissioningInfo(DiscoveredNodeData discoveredNodeData) { - if (preCommissionedVideoPlayers != null) { - long currentUnixTimeMS = System.currentTimeMillis(); - for (VideoPlayer videoPlayer : preCommissionedVideoPlayers) { - if (videoPlayer.isSameAs(discoveredNodeData)) { - Log.d( - TAG, - "Matching Video Player with the following information found for DiscoveredNodeData" - + videoPlayer); - Log.d(TAG, "Updating discovery timestamp for VideoPlayer to " + currentUnixTimeMS); - videoPlayer.setLastDiscoveredMs(currentUnixTimeMS); - discoveredNodeData.setConnectableVideoPlayer(videoPlayer); - return; - } - } - } - Log.d( - TAG, - "No matching VideoPlayers found from the cache for new DiscoveredNodeData: " - + discoveredNodeData); - } -} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java deleted file mode 100644 index 9dd0fa500d9e2b..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright (c) 2022 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. - * - */ -package com.chip.casting; - -import android.content.Context; -import android.net.nsd.NsdManager; -import android.net.wifi.WifiManager; -import android.util.Log; -import chip.appserver.ChipAppServer; -import chip.platform.AndroidBleManager; -import chip.platform.AndroidChipPlatform; -import chip.platform.ChipMdnsCallbackImpl; -import chip.platform.DiagnosticDataProviderImpl; -import chip.platform.NsdManagerServiceBrowser; -import chip.platform.NsdManagerServiceResolver; -import chip.platform.PreferencesKeyValueStoreManager; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.function.Predicate; - -public class TvCastingApp { - private static final String TAG = TvCastingApp.class.getSimpleName(); - private static final String DISCOVERY_TARGET_SERVICE_TYPE = "_matterd._udp."; - private static final List DISCOVERY_TARGET_DEVICE_TYPE_FILTER = - Arrays.asList(35L); // Video player = 35; - - // delay before which we assume undiscovered cached players may be in STR mode - private static final long CHIP_DEVICE_CONFIG_STR_DISCOVERY_DELAY_SEC = 5; - - private static TvCastingApp sInstance; - private Context applicationContext; - private ChipAppServer chipAppServer; - private NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState; - private boolean discoveryStarted = false; - private Object discoveryLock = new Object(); - - private List discoveredPlayers; - private ScheduledFuture reportSleepingVideoPlayerCommissionersFuture; - - private WifiManager.MulticastLock multicastLock; - private NsdManager nsdManager; - private NsdDiscoveryListener nsdDiscoveryListener; - - private TvCastingApp() {} - - public static TvCastingApp getInstance() { - if (sInstance == null) { - sInstance = new TvCastingApp(); - } - return sInstance; - } - - public boolean initApp(Context applicationContext, AppParameters appParameters) { - if (applicationContext == null - || appParameters == null - || appParameters.getConfigurationManager() == null) { - return false; - } - - this.applicationContext = applicationContext; - nsdManagerResolverAvailState = new NsdManagerServiceResolver.NsdManagerResolverAvailState(); - NsdManagerServiceResolver nsdManagerServiceResolver = - new NsdManagerServiceResolver(applicationContext, nsdManagerResolverAvailState); - - AndroidChipPlatform chipPlatform = - new AndroidChipPlatform( - new AndroidBleManager(), - new PreferencesKeyValueStoreManager(applicationContext), - appParameters.getConfigurationManager(), - nsdManagerServiceResolver, - new NsdManagerServiceBrowser(applicationContext), - new ChipMdnsCallbackImpl(), - new DiagnosticDataProviderImpl(applicationContext)); - - boolean ret = - chipPlatform.updateCommissionableDataProviderData( - appParameters.getSpake2pVerifierBase64(), - appParameters.getSpake2pSaltBase64(), - appParameters.getSpake2pIterationCount(), - appParameters.getSetupPasscode(), - appParameters.getDiscriminator()); - if (!ret) { - Log.e( - TAG, - "TvCastingApp.initApp failed to updateCommissionableDataProviderData on chipPlatform"); - return ret; - } - - ret = preInitJni(appParameters); - if (!ret) { - Log.e(TAG, "TvCastingApp.initApp failed in preInitJni"); - return ret; - } - - chipAppServer = new ChipAppServer(); - ret = chipAppServer.startApp(); - if (!ret) { - Log.e(TAG, "TvCastingApp.initApp failed in start chipAppServer"); - return ret; - } - - return initJni(appParameters); - } - - public native void setDACProvider(DACProvider provider); - - private native boolean preInitJni(AppParameters appParameters); - - private native boolean initJni(AppParameters appParameters); - - public void discoverVideoPlayerCommissioners( - SuccessCallback discoverySuccessCallback, - FailureCallback discoveryFailureCallback) { - synchronized (discoveryLock) { - Log.d(TAG, "TvCastingApp.discoverVideoPlayerCommissioners called"); - - if (this.discoveryStarted) { - Log.d(TAG, "Discovery already started, stopping before starting again"); - stopVideoPlayerDiscovery(); - } - - List preCommissionedVideoPlayers = readCachedVideoPlayers(); - - WifiManager wifiManager = - (WifiManager) applicationContext.getSystemService(Context.WIFI_SERVICE); - multicastLock = wifiManager.createMulticastLock("multicastLock"); - multicastLock.setReferenceCounted(true); - multicastLock.acquire(); - - nsdManager = (NsdManager) applicationContext.getSystemService(Context.NSD_SERVICE); - discoveredPlayers = new ArrayList<>(); - nsdDiscoveryListener = - new NsdDiscoveryListener( - nsdManager, - DISCOVERY_TARGET_SERVICE_TYPE, - DISCOVERY_TARGET_DEVICE_TYPE_FILTER, - preCommissionedVideoPlayers, - new SuccessCallback() { - @Override - public void handle(DiscoveredNodeData commissioner) { - Log.d(TAG, "Discovered commissioner added " + commissioner); - discoveredPlayers.add(commissioner); - discoverySuccessCallback.handle(commissioner); - } - }, - discoveryFailureCallback, - nsdManagerResolverAvailState); - - nsdManager.discoverServices( - DISCOVERY_TARGET_SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, nsdDiscoveryListener); - Log.d(TAG, "TvCastingApp.discoverVideoPlayerCommissioners started"); - - /** - * Surface players (as DiscoveredNodeData objects on discoverySuccessCallback) that we - * previously connected to and received their WakeOnLAN MACAddress, but could not discover - * over DNS-SD this time in CHIP_DEVICE_CONFIG_STR_DISCOVERY_DELAY_SEC. This API will also - * ensure that the reported players were previously discoverable within - * CHIP_DEVICE_CONFIG_STR_CACHE_LAST_DISCOVERED_HOURS. - * - *

The DiscoveredNodeData object for such players will have the IsAsleep attribute set to - * true, which can optionally be used for any special UX treatment when displaying them. - * - *

Surfacing such players as discovered will allow displaying them to the user, who may - * want to cast to them. In such a case, the VerifyOrEstablishConnection API will turn them on - * over WakeOnLan. - */ - this.reportSleepingVideoPlayerCommissionersFuture = - Executors.newScheduledThreadPool(1) - .schedule( - () -> { - Log.d( - TAG, - "Scheduling reportSleepingCommissioners with commissioner count " - + (preCommissionedVideoPlayers != null - ? preCommissionedVideoPlayers.size() - : 0)); - reportSleepingVideoPlayerCommissioners( - preCommissionedVideoPlayers, discoverySuccessCallback); - }, - CHIP_DEVICE_CONFIG_STR_DISCOVERY_DELAY_SEC * 1000, - TimeUnit.MILLISECONDS); - - this.discoveryStarted = true; - } - } - - private void reportSleepingVideoPlayerCommissioners( - List cachedVideoPlayers, - SuccessCallback discoverySuccessCallback) { - Log.d( - TAG, - "TvCastingApp.reportSleepingVideoPlayerCommissioners called with commissioner count " - + (cachedVideoPlayers != null ? cachedVideoPlayers.size() : 0)); - if (cachedVideoPlayers == null) { - Log.d(TAG, "No cached video players available."); - return; - } - - for (VideoPlayer player : cachedVideoPlayers) { - Log.d(TAG, "Cached Video Player: " + player); - // do NOT surface this cached Player if we don't have its MACAddress - if (player.getMACAddress() == null) { - Log.d( - TAG, - "TvCastingApp.reportSleepingVideoPlayerCommissioners Skipping Player with hostName" - + player.getHostName() - + " but no MACAddress"); - continue; - } - - // do NOT surface this cached Player if it has not been discoverable recently (in - // CHIP_DEVICE_CONFIG_STR_CACHE_LAST_DISCOVERED_HOURS) - if (!WasRecentlyDiscoverable(player)) { - Log.d( - TAG, - "TvCastingApp.reportSleepingVideoPlayerCommissioners Skipping Player with hostName" - + player.getHostName() - + " that has not been discovered recently"); - continue; - } - - // do NOT surface this cached Player if it was just discovered right now (in this discovery - // call) - boolean justDiscovered = - discoveredPlayers - .stream() - .anyMatch( - new Predicate() { - @Override - public boolean test(DiscoveredNodeData discoveredNodeData) { - return player.getHostName().equals(discoveredNodeData.getHostName()); - } - }); - if (justDiscovered) { - Log.d( - TAG, - "TvCastingApp.reportSleepingVideoPlayerCommissioners Skipping Player with hostName" - + player.getHostName() - + " that was just discovered"); - continue; - } - - // DO surface this cached Player (as asleep) - Log.d(TAG, "Reporting sleeping player with hostName " + player.getHostName()); - player.setIsAsleep(true); - discoverySuccessCallback.handle(new DiscoveredNodeData(player)); - } - } - - private native boolean WasRecentlyDiscoverable(VideoPlayer player); - - public void stopVideoPlayerDiscovery() { - synchronized (discoveryLock) { - Log.d(TAG, "TvCastingApp trying to stop video player discovery"); - if (this.discoveryStarted - && nsdManager != null - && multicastLock != null - && nsdDiscoveryListener != null) { - Log.d(TAG, "TvCastingApp stopping Video Player commissioner discovery"); - try { - nsdManager.stopServiceDiscovery(nsdDiscoveryListener); - } catch (IllegalArgumentException e) { - Log.w( - TAG, - "TvCastingApp received exception on calling nsdManager.stopServiceDiscovery() " - + e.getMessage()); - } - - if (multicastLock.isHeld()) { - multicastLock.release(); - } - - if (reportSleepingVideoPlayerCommissionersFuture != null) { - reportSleepingVideoPlayerCommissionersFuture.cancel(false); - } - this.discoveryStarted = false; - } - } - } - - void resetDiscoveryState() { - synchronized (discoveryLock) { - Log.d(TAG, "TvCastingApp resetting discovery state"); - this.discoveryStarted = false; - this.nsdDiscoveryListener = null; - if (multicastLock != null && multicastLock.isHeld()) { - multicastLock.release(); - } - } - } - - public native boolean openBasicCommissioningWindow( - int duration, - CommissioningCallbacks commissioningCallbacks, - SuccessCallback onConnectionSuccess, - FailureCallback onConnectionFailure, - SuccessCallback onNewOrUpdatedEndpointCallback); - - public native boolean sendCommissioningRequest(DiscoveredNodeData commissioner); - - /** @Deprecated Use sendCommissioningRequest(DiscoveredNodeData) instead */ - private native boolean sendUserDirectedCommissioningRequest(String address, int port); - - public native List readCachedVideoPlayers(); - - public native boolean verifyOrEstablishConnection( - VideoPlayer targetVideoPlayer, - SuccessCallback onConnectionSuccess, - FailureCallback onConnectionFailure, - SuccessCallback onNewOrUpdatedEndpointCallback); - - public native void shutdownAllSubscriptions(); - - public native void disconnect(); - - public native List getActiveTargetVideoPlayers(); - - public native boolean purgeCache(); - - /* - * CONTENT LAUNCHER CLUSTER - * - * TODO: Add API to subscribe to AcceptHeader - */ - public native boolean contentLauncherLaunchURL( - ContentApp contentApp, String contentUrl, String contentDisplayStr, Object launchURLHandler); - - public native boolean contentLauncher_launchContent( - ContentApp contentApp, - ContentLauncherTypes.ContentSearch search, - boolean autoPlay, - String data, - Object responseHandler); - - public native boolean contentLauncher_subscribeToSupportedStreamingProtocols( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - /* - * LEVEL CONTROL CLUSTER - */ - public native boolean levelControl_step( - ContentApp contentApp, - byte stepMode, - byte stepSize, - short transitionTime, - byte optionMask, - byte optionOverridem, - Object responseHandler); - - public native boolean levelControl_moveToLevel( - ContentApp contentApp, - byte level, - short transitionTime, - byte optionMask, - byte optionOverridem, - Object responseHandler); - - public native boolean levelControl_subscribeToCurrentLevel( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean levelControl_subscribeToMinLevel( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean levelControl_subscribeToMaxLevel( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - /* - * MEDIA PLAYBACK CLUSTER - */ - public native boolean mediaPlayback_play(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_pause(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_stopPlayback(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_next(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_previous(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_rewind(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_fastForward(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_startOver(ContentApp contentApp, Object responseHandler); - - public native boolean mediaPlayback_seek( - ContentApp contentApp, long position, Object responseHandler); - - public native boolean mediaPlayback_skipForward( - ContentApp contentApp, long deltaPositionMilliseconds, Object responseHandler); - - public native boolean mediaPlayback_skipBackward( - ContentApp contentApp, long deltaPositionMilliseconds, Object responseHandler); - - public native boolean mediaPlayback_subscribeToCurrentState( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean mediaPlayback_subscribeToDuration( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean mediaPlayback_subscribeToSampledPosition( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean mediaPlayback_subscribeToPlaybackSpeed( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean mediaPlayback_subscribeToSeekRangeEnd( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean mediaPlayback_subscribeToSeekRangeStart( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - /* - * APPLICATION LAUNCHER CLUSTER - */ - public native boolean applicationLauncher_launchApp( - ContentApp contentApp, - short catalogVendorId, - String applicationId, - byte[] data, - Object responseHandler); - - public native boolean applicationLauncher_stopApp( - ContentApp contentApp, short catalogVendorId, String applicationId, Object responseHandler); - - public native boolean applicationLauncher_hideApp( - ContentApp contentApp, short catalogVendorId, String applicationId, Object responseHandler); - - /* - * TARGET NAVIGATOR CLUSTER - */ - public native boolean targetNavigator_navigateTarget( - ContentApp contentApp, byte target, String data, Object responseHandler); - - public native boolean targetNavigator_subscribeToCurrentTarget( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean targetNavigator_subscribeToTargetList( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - /* - * KEYPAD INPUT CLUSTER - */ - public native boolean keypadInput_sendKey( - ContentApp contentApp, byte keyCode, Object responseHandler); - - /** - * APPLICATION BASIC - * - *

TODO: Add APIs to subscribe to & read Application, Status and AllowedVendorList - */ - public native boolean applicationBasic_subscribeToVendorName( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean applicationBasic_subscribeToVendorID( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean applicationBasic_subscribeToApplicationName( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean applicationBasic_subscribeToProductID( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean applicationBasic_subscribeToApplicationVersion( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler, - int minInterval, - int maxInterval, - SubscriptionEstablishedCallback subscriptionEstablishedHandler); - - public native boolean applicationBasic_readVendorName( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler); - - public native boolean applicationBasic_readVendorID( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler); - - public native boolean applicationBasic_readApplicationName( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler); - - public native boolean applicationBasic_readProductID( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler); - - public native boolean applicationBasic_readApplicationVersion( - ContentApp contentApp, - SuccessCallback readSuccessHandler, - FailureCallback readFailureHandler); - - public native boolean onOff_on(ContentApp contentApp, Object responseHandler); - - public native boolean onOff_off(ContentApp contentApp, Object responseHandler); - - public native boolean onOff_toggle(ContentApp contentApp, Object responseHandler); - - public native boolean messages_presentMessages( - ContentApp contentApp, String messageText, Object responseHandler); - - static { - System.loadLibrary("TvCastingApp"); - } -} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/DataProvider.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/DataProvider.java index 854cf76ce8aca8..63e8da3d31b609 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/DataProvider.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/DataProvider.java @@ -20,7 +20,7 @@ import android.util.Log; public interface DataProvider { - public static final String TAG = DataProvider.class.getSimpleName(); + String TAG = DataProvider.class.getSimpleName(); default T _get() { T val = null; @@ -32,5 +32,5 @@ default T _get() { return val; } - public abstract T get(); + T get(); } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h deleted file mode 100644 index 735cabf2375f51..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/Constants.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2022 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 - -enum MediaCommandName -{ - ContentLauncher_LaunchURL, - ContentLauncher_LaunchContent, - LevelControl_Step, - LevelControl_MoveToLevel, - OnOff_On, - OnOff_Off, - OnOff_Toggle, - MediaPlayback_Play, - MediaPlayback_Pause, - MediaPlayback_StopPlayback, - MediaPlayback_Next, - MediaPlayback_Previous, - MediaPlayback_Rewind, - MediaPlayback_FastForward, - MediaPlayback_StartOver, - MediaPlayback_Seek, - MediaPlayback_SkipForward, - MediaPlayback_SkipBackward, - Messages_PresentMessagesRequest, - ApplicationLauncher_LaunchApp, - ApplicationLauncher_StopApp, - ApplicationLauncher_HideApp, - TargetNavigator_NavigateTarget, - KeypadInput_SendKey, - - MEDIA_COMMAND_COUNT -}; - -enum MediaAttributeName -{ - ContentLauncher_SupportedStreamingProtocols, - ContentLauncher_AcceptHeader, - LevelControl_CurrentLevel, - LevelControl_MinLevel, - LevelControl_MaxLevel, - MediaPlayback_CurrentState, - MediaPlayback_StartTime, - MediaPlayback_Duration, - MediaPlayback_SampledPosition, - MediaPlayback_PlaybackSpeed, - MediaPlayback_SeekRangeEnd, - MediaPlayback_SeekRangeStart, - ApplicationLauncher_CurrentApp, - TargetNavigator_TargetList, - TargetNavigator_CurrentTarget, - ApplicationBasic_VendorName, - ApplicationBasic_VendorID, - ApplicationBasic_ApplicationName, - ApplicationBasic_ProductID, - ApplicationBasic_ApplicationVersion, - - MEDIA_ATTRIBUTE_COUNT -}; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp deleted file mode 100644 index c8a38942e60234..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "ConversionUtils.h" - -#include -#include -#include -#include -#include -#include -#include - -CHIP_ERROR convertJAppParametersToCppAppParams(jobject appParameters, AppParams & outAppParams) -{ - ChipLogProgress(AppServer, "convertJAppParametersToCppAppParams called"); - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturnError(appParameters != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - - jclass jAppParametersClass; - ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/AppParameters", jAppParametersClass)); - - jmethodID getRotatingDeviceIdUniqueIdMethod = env->GetMethodID(jAppParametersClass, "getRotatingDeviceIdUniqueId", "()[B"); - if (getRotatingDeviceIdUniqueIdMethod == nullptr) - { - ChipLogError(Zcl, "Failed to access AppParameters 'getRotatingDeviceIdUniqueId' method"); - env->ExceptionClear(); - } - - jobject jRotatingDeviceIdUniqueId = (jobject) env->CallObjectMethod(appParameters, getRotatingDeviceIdUniqueIdMethod); - if (env->ExceptionCheck()) - { - ChipLogError(Zcl, "Java exception in AppParameters::getRotatingDeviceIdUniqueId"); - env->ExceptionDescribe(); - env->ExceptionClear(); - return CHIP_ERROR_INCORRECT_STATE; - } - - if (jRotatingDeviceIdUniqueId != nullptr) - { - chip::JniByteArray * jniRotatingDeviceIdUniqueIdByteArray = - new chip::JniByteArray(env, static_cast(jRotatingDeviceIdUniqueId)); - outAppParams.SetRotatingDeviceIdUniqueId(MakeOptional(jniRotatingDeviceIdUniqueIdByteArray->byteSpan())); - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR convertJContentAppToTargetEndpointInfo(jobject contentApp, TargetEndpointInfo & outTargetEndpointInfo) -{ - ChipLogProgress(AppServer, "convertJContentAppToTargetEndpointInfo called"); - VerifyOrReturnError(contentApp != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass jContentAppClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); - - jfieldID jEndpointIdField = env->GetFieldID(jContentAppClass, "endpointId", "S"); - jshort jEndpointId = env->GetShortField(contentApp, jEndpointIdField); - outTargetEndpointInfo.Initialize(static_cast(jEndpointId)); - - jfieldID jclusterIdsField = env->GetFieldID(jContentAppClass, "clusterIds", "Ljava/util/List;"); - jobject jClusterIds = env->GetObjectField(contentApp, jclusterIdsField); - if (jClusterIds == nullptr) - { - return CHIP_NO_ERROR; - } - - jobject jIterator = env->CallObjectMethod( - jClusterIds, env->GetMethodID(env->GetObjectClass(jClusterIds), "iterator", "()Ljava/util/Iterator;")); - jmethodID jNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "next", "()Ljava/lang/Object;"); - jmethodID jHasNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "hasNext", "()Z"); - - while (env->CallBooleanMethod(jIterator, jHasNextMid)) - { - jobject jClusterId = env->CallObjectMethod(jIterator, jNextMid); - jclass jIntegerClass = env->FindClass("java/lang/Integer"); - jmethodID jIntValueMid = env->GetMethodID(jIntegerClass, "intValue", "()I"); - outTargetEndpointInfo.AddCluster(static_cast(env->CallIntMethod(jClusterId, jIntValueMid))); - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR convertTargetEndpointInfoToJContentApp(TargetEndpointInfo * targetEndpointInfo, jobject & outContentApp) -{ - ChipLogProgress(AppServer, "convertTargetEndpointInfoToJContentApp called"); - if (targetEndpointInfo != nullptr && targetEndpointInfo->IsInitialized()) - { - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass jContentAppClass; - ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); - jmethodID jContentAppConstructor = env->GetMethodID(jContentAppClass, "", "(SLjava/util/List;)V"); - chip::ClusterId * clusters = targetEndpointInfo->GetClusters(); - jobject jClustersArrayList = nullptr; - if (clusters != nullptr) - { - chip::JniReferences::GetInstance().CreateArrayList(jClustersArrayList); - for (size_t i = 0; i < kMaxNumberOfClustersPerEndpoint && clusters[i] != chip::kInvalidClusterId; i++) - { - jobject jCluster = nullptr; - jint jniclusterId = static_cast(clusters[i]); - chip::JniReferences::GetInstance().CreateBoxedObject("java/lang/Integer", "(I)V", jniclusterId, jCluster); - chip::JniReferences::GetInstance().AddToList(jClustersArrayList, jCluster); - } - } - outContentApp = - env->NewObject(jContentAppClass, jContentAppConstructor, targetEndpointInfo->GetEndpointId(), jClustersArrayList); - } - return CHIP_NO_ERROR; -} - -CHIP_ERROR convertJVideoPlayerToTargetVideoPlayerInfo(jobject videoPlayer, TargetVideoPlayerInfo & outTargetVideoPlayerInfo) -{ - ChipLogProgress(AppServer, "convertJVideoPlayerToTargetVideoPlayerInfo called"); - VerifyOrReturnError(videoPlayer != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass jVideoPlayerClass; - ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/VideoPlayer", jVideoPlayerClass)); - - jfieldID jNodeIdField = env->GetFieldID(jVideoPlayerClass, "nodeId", "J"); - chip::NodeId nodeId = static_cast(env->GetLongField(videoPlayer, jNodeIdField)); - - jfieldID jFabricIndexField = env->GetFieldID(jVideoPlayerClass, "fabricIndex", "B"); - chip::FabricIndex fabricIndex = static_cast(env->GetByteField(videoPlayer, jFabricIndexField)); - - jfieldID jVendorIdField = env->GetFieldID(jVideoPlayerClass, "vendorId", "I"); - uint16_t vendorId = static_cast(env->GetIntField(videoPlayer, jVendorIdField)); - - jfieldID jProductIdField = env->GetFieldID(jVideoPlayerClass, "productId", "I"); - uint16_t productId = static_cast(env->GetIntField(videoPlayer, jProductIdField)); - - jfieldID jDeviceType = env->GetFieldID(jVideoPlayerClass, "deviceType", "I"); - uint16_t deviceType = static_cast(env->GetIntField(videoPlayer, jDeviceType)); - - jfieldID getDeviceNameField = env->GetFieldID(jVideoPlayerClass, "deviceName", "Ljava/lang/String;"); - jstring jDeviceName = static_cast(env->GetObjectField(videoPlayer, getDeviceNameField)); - const char * deviceName = env->GetStringUTFChars(jDeviceName, 0); - - jfieldID getHostNameField = env->GetFieldID(jVideoPlayerClass, "hostName", "Ljava/lang/String;"); - jstring jHostName = static_cast(env->GetObjectField(videoPlayer, getHostNameField)); - const char * hostName = env->GetStringUTFChars(jHostName, 0); - - jfieldID jPort = env->GetFieldID(jVideoPlayerClass, "port", "I"); - uint16_t port = static_cast(env->GetIntField(videoPlayer, jPort)); - - jfieldID getInstanceNameField = env->GetFieldID(jVideoPlayerClass, "instanceName", "Ljava/lang/String;"); - jstring jInstanceName = static_cast(env->GetObjectField(videoPlayer, getInstanceNameField)); - const char * instanceName = {}; - if (jInstanceName != nullptr) - { - instanceName = env->GetStringUTFChars(jInstanceName, 0); - } - - jfieldID jLastDiscoveredMs = env->GetFieldID(jVideoPlayerClass, "lastDiscoveredMs", "J"); - long lastDiscoveredMs = static_cast(env->GetLongField(videoPlayer, jLastDiscoveredMs)); - - jfieldID getMACAddressField = env->GetFieldID(jVideoPlayerClass, "MACAddress", "Ljava/lang/String;"); - jstring jMACAddress = static_cast(env->GetObjectField(videoPlayer, getMACAddressField)); - const char * MACAddress = jMACAddress == nullptr ? nullptr : env->GetStringUTFChars(jMACAddress, 0); - - jfieldID jIsAsleep = env->GetFieldID(jVideoPlayerClass, "isAsleep", "Z"); - bool isAsleep = static_cast(env->GetBooleanField(videoPlayer, jIsAsleep)); - - outTargetVideoPlayerInfo.Initialize(nodeId, fabricIndex, nullptr, nullptr, vendorId, productId, deviceType, deviceName, - hostName, 0, nullptr, port, instanceName, chip::System::Clock::Timestamp(lastDiscoveredMs)); - - if (MACAddress != nullptr) - { - chip::CharSpan MACAddressSpan(MACAddress, 2 * 2 * chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength); - outTargetVideoPlayerInfo.SetMACAddress(MACAddressSpan); - } - - outTargetVideoPlayerInfo.SetIsAsleep(isAsleep); - - jfieldID jContentAppsField = env->GetFieldID(jVideoPlayerClass, "contentApps", "Ljava/util/List;"); - jobject jContentApps = env->GetObjectField(videoPlayer, jContentAppsField); - if (jContentApps == nullptr) - { - return CHIP_NO_ERROR; - } - - jobject jIterator = env->CallObjectMethod( - jContentApps, env->GetMethodID(env->GetObjectClass(jContentApps), "iterator", "()Ljava/util/Iterator;")); - jmethodID jNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "next", "()Ljava/lang/Object;"); - jmethodID jHasNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "hasNext", "()Z"); - - while (env->CallBooleanMethod(jIterator, jHasNextMid)) - { - jobject jContentApp = env->CallObjectMethod(jIterator, jNextMid); - - jclass jContentAppClass; - ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentApp", jContentAppClass)); - jfieldID jEndpointIdField = env->GetFieldID(jContentAppClass, "endpointId", "S"); - chip::EndpointId endpointId = static_cast(env->GetShortField(jContentApp, jEndpointIdField)); - TargetEndpointInfo * endpoint = outTargetVideoPlayerInfo.GetOrAddEndpoint(endpointId); - - ReturnErrorOnFailure(convertJContentAppToTargetEndpointInfo(jContentApp, *endpoint)); - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR convertTargetVideoPlayerInfoToJVideoPlayer(TargetVideoPlayerInfo * targetVideoPlayerInfo, jobject & outVideoPlayer) -{ - ChipLogProgress(AppServer, "convertTargetVideoPlayerInfoToJVideoPlayer called"); - if (targetVideoPlayerInfo != nullptr && targetVideoPlayerInfo->IsInitialized()) - { - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass jVideoPlayerClass; - ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/VideoPlayer", jVideoPlayerClass)); - jmethodID jVideoPlayerConstructor = env->GetMethodID(jVideoPlayerClass, "", - "(JBLjava/lang/String;IIILjava/util/List;ILjava/util/List;Ljava/lang/" - "String;Ljava/lang/String;IJLjava/lang/String;ZZ)V"); - - jobject jContentAppList = nullptr; - TargetEndpointInfo * endpoints = targetVideoPlayerInfo->GetEndpoints(); - if (endpoints != nullptr) - { - chip::JniReferences::GetInstance().CreateArrayList(jContentAppList); - for (size_t i = 0; i < kMaxNumberOfEndpoints && endpoints[i].IsInitialized(); i++) - { - jobject contentApp = nullptr; - ReturnErrorOnFailure(convertTargetEndpointInfoToJContentApp(&endpoints[i], contentApp)); - chip::JniReferences::GetInstance().AddToList(jContentAppList, contentApp); - } - } - - jstring deviceName = - targetVideoPlayerInfo->GetDeviceName() == nullptr ? nullptr : env->NewStringUTF(targetVideoPlayerInfo->GetDeviceName()); - - jstring hostName = - targetVideoPlayerInfo->GetHostName() == nullptr ? nullptr : env->NewStringUTF(targetVideoPlayerInfo->GetHostName()); - - jstring instanceName = targetVideoPlayerInfo->GetInstanceName() == nullptr - ? nullptr - : env->NewStringUTF(targetVideoPlayerInfo->GetInstanceName()); - - jstring MACAddress = nullptr; - if (targetVideoPlayerInfo->GetMACAddress() != nullptr && targetVideoPlayerInfo->GetMACAddress()->data() != nullptr) - { - char MACAddressWithNil[2 * chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength + 1]; - memcpy(MACAddressWithNil, targetVideoPlayerInfo->GetMACAddress()->data(), - targetVideoPlayerInfo->GetMACAddress()->size()); - MACAddressWithNil[targetVideoPlayerInfo->GetMACAddress()->size()] = '\0'; - MACAddress = env->NewStringUTF(MACAddressWithNil); - } - - jobject jIPAddressList = nullptr; - const chip::Inet::IPAddress * ipAddresses = targetVideoPlayerInfo->GetIpAddresses(); - if (ipAddresses != nullptr) - { - chip::JniReferences::GetInstance().CreateArrayList(jIPAddressList); - for (size_t i = 0; i < targetVideoPlayerInfo->GetNumIPs() && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; - i++) - { - char addrCString[chip::Inet::IPAddress::kMaxStringLength]; - ipAddresses[i].ToString(addrCString, chip::Inet::IPAddress::kMaxStringLength); - jstring jIPAddressStr = env->NewStringUTF(addrCString); - - jclass jIPAddressClass; - ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/net/InetAddress", jIPAddressClass)); - jmethodID jGetByNameMid = - env->GetStaticMethodID(jIPAddressClass, "getByName", "(Ljava/lang/String;)Ljava/net/InetAddress;"); - jobject jIPAddress = env->CallStaticObjectMethod(jIPAddressClass, jGetByNameMid, jIPAddressStr); - - chip::JniReferences::GetInstance().AddToList(jIPAddressList, jIPAddress); - } - } - - outVideoPlayer = env->NewObject( - jVideoPlayerClass, jVideoPlayerConstructor, targetVideoPlayerInfo->GetNodeId(), targetVideoPlayerInfo->GetFabricIndex(), - deviceName, targetVideoPlayerInfo->GetVendorId(), targetVideoPlayerInfo->GetProductId(), - targetVideoPlayerInfo->GetDeviceType(), jContentAppList, targetVideoPlayerInfo->GetNumIPs(), jIPAddressList, hostName, - instanceName, targetVideoPlayerInfo->GetPort(), targetVideoPlayerInfo->GetLastDiscovered().count(), MACAddress, - targetVideoPlayerInfo->IsAsleep(), targetVideoPlayerInfo->GetOperationalDeviceProxy() != nullptr); - } - return CHIP_NO_ERROR; -} - -CHIP_ERROR convertJDiscoveredNodeDataToCppDiscoveredNodeData(jobject jDiscoveredNodeData, - chip::Dnssd::CommissionNodeData & outCppDiscoveredNodeData) -{ - ChipLogProgress(AppServer, "convertJDiscoveredNodeDataToCppDiscoveredNodeData called"); - VerifyOrReturnError(jDiscoveredNodeData != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass jDiscoveredNodeDataClass; - ReturnErrorOnFailure( - chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/DiscoveredNodeData", jDiscoveredNodeDataClass)); - - jfieldID getHostNameField = env->GetFieldID(jDiscoveredNodeDataClass, "hostName", "Ljava/lang/String;"); - jstring jHostName = static_cast(env->GetObjectField(jDiscoveredNodeData, getHostNameField)); - if (jHostName != nullptr) - { - chip::Platform::CopyString(outCppDiscoveredNodeData.hostName, chip::Dnssd::kHostNameMaxLength + 1, - env->GetStringUTFChars(jHostName, 0)); - } - - jfieldID getInstanceNameField = env->GetFieldID(jDiscoveredNodeDataClass, "instanceName", "Ljava/lang/String;"); - jstring jInstanceName = static_cast(env->GetObjectField(jDiscoveredNodeData, getInstanceNameField)); - if (jInstanceName != nullptr) - { - chip::Platform::CopyString(outCppDiscoveredNodeData.instanceName, chip::Dnssd::Commission::kInstanceNameMaxLength + 1, - env->GetStringUTFChars(jInstanceName, 0)); - } - - jfieldID jLongDiscriminatorField = env->GetFieldID(jDiscoveredNodeDataClass, "longDiscriminator", "J"); - outCppDiscoveredNodeData.vendorId = static_cast(env->GetLongField(jDiscoveredNodeData, jLongDiscriminatorField)); - - jfieldID jVendorIdField = env->GetFieldID(jDiscoveredNodeDataClass, "vendorId", "J"); - outCppDiscoveredNodeData.vendorId = static_cast(env->GetLongField(jDiscoveredNodeData, jVendorIdField)); - - jfieldID jProductIdField = env->GetFieldID(jDiscoveredNodeDataClass, "productId", "J"); - outCppDiscoveredNodeData.productId = static_cast(env->GetLongField(jDiscoveredNodeData, jProductIdField)); - - jfieldID jCommissioningModeField = env->GetFieldID(jDiscoveredNodeDataClass, "commissioningMode", "B"); - outCppDiscoveredNodeData.commissioningMode = - static_cast(env->GetByteField(jDiscoveredNodeData, jCommissioningModeField)); - - jfieldID jDeviceTypeField = env->GetFieldID(jDiscoveredNodeDataClass, "deviceType", "J"); - outCppDiscoveredNodeData.deviceType = static_cast(env->GetLongField(jDiscoveredNodeData, jDeviceTypeField)); - - jfieldID getDeviceNameField = env->GetFieldID(jDiscoveredNodeDataClass, "deviceName", "Ljava/lang/String;"); - jstring jDeviceName = static_cast(env->GetObjectField(jDiscoveredNodeData, getDeviceNameField)); - if (jDeviceName != nullptr) - { - chip::Platform::CopyString(outCppDiscoveredNodeData.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, - env->GetStringUTFChars(jDeviceName, 0)); - } - - // TODO: map rotating ID - jfieldID jRotatingIdLenField = env->GetFieldID(jDiscoveredNodeDataClass, "rotatingIdLen", "I"); - outCppDiscoveredNodeData.rotatingIdLen = static_cast(env->GetIntField(jDiscoveredNodeData, jRotatingIdLenField)); - - jfieldID jPairingHintField = env->GetFieldID(jDiscoveredNodeDataClass, "pairingHint", "S"); - outCppDiscoveredNodeData.pairingHint = static_cast(env->GetShortField(jDiscoveredNodeData, jPairingHintField)); - - jfieldID getPairingInstructionField = env->GetFieldID(jDiscoveredNodeDataClass, "pairingInstruction", "Ljava/lang/String;"); - jstring jPairingInstruction = static_cast(env->GetObjectField(jDiscoveredNodeData, getPairingInstructionField)); - if (jPairingInstruction != nullptr) - { - chip::Platform::CopyString(outCppDiscoveredNodeData.pairingInstruction, chip::Dnssd::kMaxPairingInstructionLen + 1, - env->GetStringUTFChars(jPairingInstruction, 0)); - } - - jfieldID jPortField = env->GetFieldID(jDiscoveredNodeDataClass, "port", "I"); - outCppDiscoveredNodeData.port = static_cast(env->GetIntField(jDiscoveredNodeData, jPortField)); - - jfieldID jNumIpsField = env->GetFieldID(jDiscoveredNodeDataClass, "numIPs", "I"); - outCppDiscoveredNodeData.numIPs = static_cast(env->GetIntField(jDiscoveredNodeData, jNumIpsField)); - - jfieldID jIPAddressesField = env->GetFieldID(jDiscoveredNodeDataClass, "ipAddresses", "Ljava/util/List;"); - jobject jIPAddresses = env->GetObjectField(jDiscoveredNodeData, jIPAddressesField); - if (jIPAddresses == nullptr && outCppDiscoveredNodeData.numIPs > 0) - { - return CHIP_ERROR_INVALID_ARGUMENT; - } - - jobject jIterator = env->CallObjectMethod( - jIPAddresses, env->GetMethodID(env->GetObjectClass(jIPAddresses), "iterator", "()Ljava/util/Iterator;")); - jmethodID jNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "next", "()Ljava/lang/Object;"); - jmethodID jHasNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "hasNext", "()Z"); - - size_t ipAddressCount = 0; - while (env->CallBooleanMethod(jIterator, jHasNextMid)) - { - jobject jIPAddress = env->CallObjectMethod(jIterator, jNextMid); - jclass jIPAddressClass; - ReturnErrorOnFailure(chip::JniReferences::GetInstance().GetLocalClassRef(env, "java/net/InetAddress", jIPAddressClass)); - jmethodID jGetHostAddressMid = env->GetMethodID(jIPAddressClass, "getHostAddress", "()Ljava/lang/String;"); - jstring jIPAddressStr = static_cast(env->CallObjectMethod(jIPAddress, jGetHostAddressMid)); - - chip::Inet::IPAddress addressInet; - chip::JniUtfString addressJniString(env, jIPAddressStr); - VerifyOrReturnError(chip::Inet::IPAddress::FromString(addressJniString.c_str(), addressInet), CHIP_ERROR_INVALID_ARGUMENT); - outCppDiscoveredNodeData.ipAddress[ipAddressCount] = addressInet; - - if (ipAddressCount == 0) - { - outCppDiscoveredNodeData.interfaceId = chip::Inet::InterfaceId::FromIPAddress(addressInet); - } - ipAddressCount++; - } - - return CHIP_NO_ERROR; -} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.h deleted file mode 100644 index 28f5a1abd28c5a..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright (c) 2021 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 "AppParams.h" -#include "TargetEndpointInfo.h" -#include "TargetVideoPlayerInfo.h" - -#include - -CHIP_ERROR convertJAppParametersToCppAppParams(jobject appParameters, AppParams & outAppParams); - -CHIP_ERROR convertJContentAppToTargetEndpointInfo(jobject contentApp, TargetEndpointInfo & outTargetEndpointInfo); - -CHIP_ERROR convertTargetEndpointInfoToJContentApp(TargetEndpointInfo * targetEndpointInfo, jobject & outContentApp); - -CHIP_ERROR convertJVideoPlayerToTargetVideoPlayerInfo(jobject videoPlayer, TargetVideoPlayerInfo & targetVideoPlayerInfo); - -CHIP_ERROR convertTargetVideoPlayerInfoToJVideoPlayer(TargetVideoPlayerInfo * targetVideoPlayerInfo, jobject & outVideoPlayer); - -CHIP_ERROR convertJDiscoveredNodeDataToCppDiscoveredNodeData(jobject jDiscoveredNodeData, - chip::Dnssd::CommissionNodeData & cppDiscoveredNodeData); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp deleted file mode 100644 index ca62ba5f37ee22..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/* - * - * Copyright (c) 2022 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 "MatterCallbackHandler-JNI.h" - -#include - -using namespace chip; - -CHIP_ERROR CallbackBaseJNI::SetUp(JNIEnv * env, jobject inHandler) -{ - ChipLogProgress(AppServer, "CallbackBaseJNI::SetUp called"); - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(mObject.Init(inHandler) == CHIP_NO_ERROR, ChipLogError(AppServer, "Failed to Init mObject")); - - mClazz = env->GetObjectClass(mObject.ObjectRef()); - VerifyOrExit(mClazz != nullptr, ChipLogError(AppServer, "Failed to get handler Java class")); - - mSuperClazz = env->GetSuperclass(mClazz); - VerifyOrExit(mSuperClazz != nullptr, ChipLogError(AppServer, "Failed to get handler's parent's Java class")); - - mMethod = env->GetMethodID(mSuperClazz, "handleInternal", mMethodSignature); - if (mMethod == nullptr) - { - ChipLogError(AppServer, "Failed to access 'handleInternal' method with signature %s", mMethodSignature); - env->ExceptionClear(); - } - -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "CallbackBaseJNI::SetUp error: %s", err.AsString()); - return err; - } - - return err; -} - -void FailureHandlerJNI::Handle(CHIP_ERROR callbackErr) -{ - ChipLogProgress(AppServer, "Handle(CHIP_ERROR) called"); - - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - UtfString jniCallbackErrString(env, callbackErr.AsString()); - - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit(mObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - env->CallVoidMethod(mObject.ObjectRef(), mMethod, static_cast(callbackErr.AsInteger()), jniCallbackErrString.jniValue()); -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Handle(CHIP_ERROR) status error: %s", err.AsString()); - } -} - -void SubscriptionEstablishedHandlerJNI::Handle() -{ - ChipLogProgress(AppServer, "SubscriptionEstablishedHandlerJNI::Handle called"); - - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit(mObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - env->CallVoidMethod(mObject.ObjectRef(), mMethod); -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "SubscriptionEstablishedHandlerJNI::Handle status error: %s", err.AsString()); - } -} - -jobject ConvertToLongJObject(uint64_t responseData) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass responseTypeClass = env->FindClass("java/lang/Long"); - if (responseTypeClass == nullptr) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(J)V"); - return env->NewObject(responseTypeClass, constructor, responseData); -} - -jobject ConvertToFloatJObject(float responseData) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass responseTypeClass = env->FindClass("java/lang/Float"); - if (responseTypeClass == nullptr) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(F)V"); - return env->NewObject(responseTypeClass, constructor, responseData); -} - -jobject ConvertToShortJObject(uint16_t responseData) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass responseTypeClass = env->FindClass("java/lang/Short"); - if (responseTypeClass == nullptr) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(S)V"); - return env->NewObject(responseTypeClass, constructor, responseData); -} - -jobject ConvertToByteJObject(uint8_t responseData) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass responseTypeClass = env->FindClass("java/lang/Byte"); - if (responseTypeClass == nullptr) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(B)V"); - return env->NewObject(responseTypeClass, constructor, responseData); -} - -jstring ConvertToJString(chip::CharSpan responseData) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - - return env->NewStringUTF(std::string(responseData.data(), responseData.size()).c_str()); -} - -jobject ConvertToIntegerJObject(uint32_t responseData) -{ - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - - jclass responseTypeClass = env->FindClass("java/lang/Integer"); - if (responseTypeClass == nullptr) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(I)V"); - return env->NewObject(responseTypeClass, constructor, responseData); -} - -// COMMISSIONING AND CONNECTION -jobject OnConnectionSuccessHandlerJNI::ConvertToJObject(TargetVideoPlayerInfo * targetVideoPlayerInfo) -{ - ChipLogProgress(AppServer, "OnConnectionSuccessHandlerJNI::ConvertToJObject called"); - jobject videoPlayer = nullptr; - CHIP_ERROR err = convertTargetVideoPlayerInfoToJVideoPlayer(targetVideoPlayerInfo, videoPlayer); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "OnConnectionSuccessHandlerJNI::ConvertToJObject failed with %" CHIP_ERROR_FORMAT, err.Format()); - } - return videoPlayer; -} - -jobject OnNewOrUpdatedEndpointHandlerJNI::ConvertToJObject(TargetEndpointInfo * targetEndpointInfo) -{ - ChipLogProgress(AppServer, "OnNewOrUpdatedEndpointHandlerJNI::ConvertToJObject called"); - jobject contentApp = nullptr; - CHIP_ERROR err = convertTargetEndpointInfoToJContentApp(targetEndpointInfo, contentApp); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "OnNewOrUpdatedEndpointHandlerJNI::ConvertToJObject failed with %" CHIP_ERROR_FORMAT, err.Format()); - } - return contentApp; -} - -// MEDIA PLAYBACK -jobject CurrentStateSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::MediaPlayback::Attributes::CurrentState::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "CurrentStateSuccessHandlerJNI::ConvertToJObject called"); - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturnValue(env != nullptr, nullptr); - JniLocalReferenceScope scope(env); - - jclass enumClass = nullptr; - CHIP_ERROR err = - JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/MediaPlaybackTypes$PlaybackStateEnum", enumClass); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - jfieldID enumType = nullptr; - switch (responseData) - { - case chip::app::Clusters::MediaPlayback::PlaybackStateEnum::kPlaying: - enumType = env->GetStaticFieldID(enumClass, "Playing", "Lcom/chip/casting/MediaPlaybackTypes$PlaybackStateEnum;"); - break; - case chip::app::Clusters::MediaPlayback::PlaybackStateEnum::kPaused: - enumType = env->GetStaticFieldID(enumClass, "Paused", "Lcom/chip/casting/MediaPlaybackTypes$PlaybackStateEnum;"); - break; - case chip::app::Clusters::MediaPlayback::PlaybackStateEnum::kNotPlaying: - enumType = env->GetStaticFieldID(enumClass, "NotPlaying", "Lcom/chip/casting/MediaPlaybackTypes$PlaybackStateEnum;"); - break; - case chip::app::Clusters::MediaPlayback::PlaybackStateEnum::kBuffering: - enumType = env->GetStaticFieldID(enumClass, "Buffering", "Lcom/chip/casting/MediaPlaybackTypes$PlaybackStateEnum;"); - break; - default: - enumType = env->GetStaticFieldID(enumClass, "Unknown", "Lcom/chip/casting/MediaPlaybackTypes$PlaybackStateEnum;"); - break; - } - - if (enumType != nullptr) - { - return env->GetStaticObjectField(enumClass, enumType); - } - return nullptr; -} - -jobject DurationSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::MediaPlayback::Attributes::Duration::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "DurationSuccessHandlerJNI::ConvertToJObject called"); - return responseData.IsNull() ? nullptr : ConvertToLongJObject(responseData.Value()); -} - -jobject SampledPositionSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "SampledPositionSuccessHandlerJNI::ConvertToJObject called"); - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturnValue(env != nullptr, nullptr); - JniLocalReferenceScope scope(env); - - jobject jSampledPosition = nullptr; - if (!responseData.IsNull()) - { - const chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::DecodableType & playbackPosition = - responseData.Value(); - - jclass responseTypeClass = nullptr; - CHIP_ERROR err = JniReferences::GetInstance().GetLocalClassRef( - env, "com/chip/casting/MediaPlaybackTypes$PlaybackPositionStruct", responseTypeClass); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - if (playbackPosition.position.IsNull()) - { - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(Ljava/lang/Long;)V"); - jSampledPosition = env->NewObject(responseTypeClass, constructor, playbackPosition.updatedAt); - } - else - { - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(Ljava/lang/Long;java/lang/Long;)V"); - jSampledPosition = - env->NewObject(responseTypeClass, constructor, playbackPosition.updatedAt, playbackPosition.position.Value()); - } - } - - return jSampledPosition; -} - -jobject PlaybackSpeedSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::MediaPlayback::Attributes::PlaybackSpeed::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "PlaybackSpeedSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToFloatJObject(responseData); -} - -jobject SeekRangeEndSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::MediaPlayback::Attributes::SeekRangeEnd::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "SeekRangeEndSuccessHandlerJNI::ConvertToJObject called"); - return responseData.IsNull() ? nullptr : ConvertToLongJObject(responseData.Value()); -} - -jobject SeekRangeStartSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::MediaPlayback::Attributes::SeekRangeStart::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "SeekRangeStartSuccessHandlerJNI::ConvertToJObject called"); - return responseData.IsNull() ? nullptr : ConvertToLongJObject(responseData.Value()); -} - -// TARGET NAVIGATOR -jobject CurrentTargetSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "CurrentTargetSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToByteJObject(responseData); -} - -jobject TargetListSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::TargetNavigator::Attributes::TargetList::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "TargetListSuccessHandlerJNI::ConvertToJObject called"); - - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); - VerifyOrReturnValue(env != nullptr, nullptr); - JniLocalReferenceScope scope(env); - - jobject jArrayList; - chip::JniReferences::GetInstance().CreateArrayList(jArrayList); - auto iter = responseData.begin(); - while (iter.Next()) - { - const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & targetInfo = iter.GetValue(); - - jclass responseTypeClass = nullptr; - CHIP_ERROR err = JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/TargetNavigatorTypes$TargetInfo", - responseTypeClass); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "ConvertToJObject: Class for Response Type not found!"); - return nullptr; - } - - jmethodID constructor = env->GetMethodID(responseTypeClass, "", "(Ljava/lang/Integer;Ljava/lang/String;)V"); - chip::UtfString targetInfoName(env, targetInfo.name); - jobject jTargetInfo = env->NewObject(responseTypeClass, constructor, ConvertToIntegerJObject(targetInfo.identifier), - targetInfoName.jniValue()); - - chip::JniReferences::GetInstance().AddToList(jArrayList, jTargetInfo); - } - return jArrayList; -} - -// LEVEL CONTROL -jobject CurrentLevelSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::LevelControl::Attributes::CurrentLevel::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "CurrentLevelSuccessHandlerJNI::ConvertToJObject called"); - return responseData.IsNull() ? nullptr : ConvertToByteJObject(responseData.Value()); -} - -jobject MinLevelSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::LevelControl::Attributes::MinLevel::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "MinLevelSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToByteJObject(responseData); -} - -jobject MaxLevelSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::LevelControl::Attributes::MaxLevel::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "MaxLevelSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToByteJObject(responseData); -} - -// CONTENT LAUNCHER -jobject SupportedStreamingProtocolsSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "SupportedStreamingProtocolsSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToIntegerJObject(responseData.Raw()); -} - -// APPLICATION BASIC -jobject VendorNameSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "VendorNameSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToJString(responseData); -} - -jobject VendorIDSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "VendorIDSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToIntegerJObject(responseData); -} - -jobject ApplicationNameSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "ApplicationNameSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToJString(responseData); -} - -jobject ProductIDSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "ProductIDSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToIntegerJObject(responseData); -} - -jobject ApplicationVersionSuccessHandlerJNI::ConvertToJObject( - chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType responseData) -{ - ChipLogProgress(AppServer, "ApplicationVersionSuccessHandlerJNI::ConvertToJObject called"); - return ConvertToJString(responseData); -} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h deleted file mode 100644 index 152dac59737532..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h +++ /dev/null @@ -1,293 +0,0 @@ -/* - * - * Copyright (c) 2022 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 "ConversionUtils.h" -#include "TargetEndpointInfo.h" -#include "TargetVideoPlayerInfo.h" - -#include -#include -#include -#include -#include - -#include - -class CallbackBaseJNI -{ -public: - CallbackBaseJNI(const char * methodSignature) { mMethodSignature = methodSignature; } - CHIP_ERROR SetUp(JNIEnv * env, jobject inHandler); - -protected: - chip::JniGlobalReference mObject; - jclass mClazz = nullptr; - jclass mSuperClazz = nullptr; - jmethodID mMethod = nullptr; - const char * mMethodSignature = nullptr; -}; - -class FailureHandlerJNI : public CallbackBaseJNI -{ -public: - FailureHandlerJNI() : CallbackBaseJNI("(ILjava/lang/String;)V") {} - void Handle(CHIP_ERROR err); -}; - -class MatterCallbackHandlerJNI : public FailureHandlerJNI -{ -}; - -class SubscriptionEstablishedHandlerJNI : public CallbackBaseJNI -{ -public: - SubscriptionEstablishedHandlerJNI() : CallbackBaseJNI("()V") {} - void Handle(); -}; - -// helper functions for conversions -jobject ConvertToLongJObject(uint64_t responseData); -jobject ConvertToFloatJObject(float responseData); -jobject ConvertToShortJObject(uint8_t responseData); -jobject ConvertToByteJObject(uint8_t responseData); -jobject ConvertToIntegerJObject(uint32_t responseData); -jstring ConvertToJString(chip::CharSpan responseData); - -template -class SuccessHandlerJNI : public CallbackBaseJNI -{ -public: - SuccessHandlerJNI(const char * methodSignature) : CallbackBaseJNI(methodSignature) {} - - virtual ~SuccessHandlerJNI() = 0; - - virtual jobject ConvertToJObject(T responseData) = 0; - - void Handle(T responseData) - { - ChipLogProgress(AppServer, "SuccessHandlerJNI::Handle called"); - - JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); - jobject jResponseData = ConvertToJObject(responseData); - - chip::DeviceLayer::StackUnlock unlock; - CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit(mObject.HasValidObjectRef(), err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mMethod != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - env->CallVoidMethod(mObject.ObjectRef(), mMethod, jResponseData); - exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "SuccessHandlerJNI::Handle status error: %s", err.AsString()); - } - } -}; - -template -SuccessHandlerJNI::~SuccessHandlerJNI(){}; - -// COMMISSIONING AND CONNECTION -class SessionEstablishmentStartedHandlerJNI : public SuccessHandlerJNI -{ -public: - SessionEstablishmentStartedHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {} - jobject ConvertToJObject(void * responseData) - { - // return nullptr because the Java callback extends SuccessCallback and its handle() expects a Void param. - // It expects a Void becauase no value is passed as part of this callback. - return nullptr; - } -}; - -class SessionEstablishedHandlerJNI : public SuccessHandlerJNI -{ -public: - SessionEstablishedHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {} - jobject ConvertToJObject(void * responseData) - { - // return nullptr because the Java callback extends SuccessCallback and its handle() expects a Void param. - // It expects a Void becauase no value is passed as part of this callback. - return nullptr; - } -}; - -class OnConnectionSuccessHandlerJNI : public SuccessHandlerJNI -{ -public: - OnConnectionSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {} - jobject ConvertToJObject(TargetVideoPlayerInfo * responseData); -}; - -class OnNewOrUpdatedEndpointHandlerJNI : public SuccessHandlerJNI -{ -public: - OnNewOrUpdatedEndpointHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {} - jobject ConvertToJObject(TargetEndpointInfo * responseData); -}; - -// MEDIA PLAYBACK -class CurrentStateSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - CurrentStateSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {} - jobject ConvertToJObject(chip::app::Clusters::MediaPlayback::Attributes::CurrentState::TypeInfo::DecodableArgType responseData); -}; - -class DurationSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - DurationSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Long;)V") {} - jobject ConvertToJObject(chip::app::Clusters::MediaPlayback::Attributes::Duration::TypeInfo::DecodableArgType responseData); -}; - -class SampledPositionSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - SampledPositionSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {} - jobject - ConvertToJObject(chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::TypeInfo::DecodableArgType responseData); -}; - -class PlaybackSpeedSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - PlaybackSpeedSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Float;)V") {} - jobject - ConvertToJObject(chip::app::Clusters::MediaPlayback::Attributes::PlaybackSpeed::TypeInfo::DecodableArgType responseData); -}; - -class SeekRangeEndSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - SeekRangeEndSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Long;)V") {} - jobject ConvertToJObject(chip::app::Clusters::MediaPlayback::Attributes::SeekRangeEnd::TypeInfo::DecodableArgType responseData); -}; - -class SeekRangeStartSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - SeekRangeStartSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Long;)V") {} - jobject - ConvertToJObject(chip::app::Clusters::MediaPlayback::Attributes::SeekRangeStart::TypeInfo::DecodableArgType responseData); -}; - -// TARGET NAVIGATOR -class CurrentTargetSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - CurrentTargetSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Byte;)V") {} - jobject - ConvertToJObject(chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::TypeInfo::DecodableArgType responseData); -}; - -class TargetListSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - TargetListSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {} - jobject ConvertToJObject(chip::app::Clusters::TargetNavigator::Attributes::TargetList::TypeInfo::DecodableArgType responseData); -}; - -// LEVEL CONTROL -class CurrentLevelSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - CurrentLevelSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Byte;)V") {} - jobject ConvertToJObject(chip::app::Clusters::LevelControl::Attributes::CurrentLevel::TypeInfo::DecodableArgType responseData); -}; - -class MinLevelSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - MinLevelSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Byte;)V") {} - jobject ConvertToJObject(chip::app::Clusters::LevelControl::Attributes::MinLevel::TypeInfo::DecodableArgType responseData); -}; - -class MaxLevelSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - MaxLevelSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Byte;)V") {} - jobject ConvertToJObject(chip::app::Clusters::LevelControl::Attributes::MaxLevel::TypeInfo::DecodableArgType responseData); -}; - -// CONTENT LAUNCHER -class SupportedStreamingProtocolsSuccessHandlerJNI - : public SuccessHandlerJNI< - chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo::DecodableArgType> -{ -public: - SupportedStreamingProtocolsSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Integer;)V") {} - jobject ConvertToJObject( - chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo::DecodableArgType responseData); -}; - -// APPLICATION BASIC -class VendorNameSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - VendorNameSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/String;)V") {} - jobject - ConvertToJObject(chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType responseData); -}; - -class VendorIDSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - VendorIDSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Integer;)V") {} - jobject ConvertToJObject(chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType responseData); -}; - -class ApplicationNameSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - ApplicationNameSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/String;)V") {} - jobject - ConvertToJObject(chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType responseData); -}; - -class ProductIDSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - ProductIDSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Integer;)V") {} - jobject ConvertToJObject(chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType responseData); -}; - -class ApplicationVersionSuccessHandlerJNI - : public SuccessHandlerJNI -{ -public: - ApplicationVersionSuccessHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/String;)V") {} - jobject ConvertToJObject( - chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType responseData); -}; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp deleted file mode 100644 index f2e0d5b79fc53c..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp +++ /dev/null @@ -1,2129 +0,0 @@ -/* - * Copyright (c) 2022 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 "TvCastingApp-JNI.h" -#include "CastingServer.h" -#include "Constants.h" -#include "ConversionUtils.h" -#include "JNIDACProvider.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; - -#define JNI_METHOD(RETURN, METHOD_NAME) extern "C" JNIEXPORT RETURN JNICALL Java_com_chip_casting_TvCastingApp_##METHOD_NAME - -TvCastingAppJNI TvCastingAppJNI::sInstance; - -jint JNI_OnLoad(JavaVM * jvm, void * reserved) -{ - return AndroidAppServerJNI_OnLoad(jvm, reserved); -} - -void JNI_OnUnload(JavaVM * jvm, void * reserved) -{ - return AndroidAppServerJNI_OnUnload(jvm, reserved); -} - -JNI_METHOD(jboolean, preInitJni)(JNIEnv *, jobject, jobject jAppParameters) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD preInitJni called"); - - CHIP_ERROR err = CHIP_NO_ERROR; - if (jAppParameters == nullptr) - { - err = CastingServer::GetInstance()->PreInit(); - } - else - { - AppParams appParams; - err = convertJAppParametersToCppAppParams(jAppParameters, appParams); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion of AppParameters from jobject to Cpp type failed: %" CHIP_ERROR_FORMAT, - err.Format())); - err = CastingServer::GetInstance()->PreInit(&appParams); - } - VerifyOrExit( - err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Call to CastingServer::GetInstance()->PreInit() failed: %" CHIP_ERROR_FORMAT, err.Format())); -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, initJni)(JNIEnv *, jobject, jobject jAppParameters) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD initJni called"); - - CHIP_ERROR err = CHIP_NO_ERROR; - if (jAppParameters == nullptr) - { - err = CastingServer::GetInstance()->Init(); - } - else - { - AppParams appParams; - err = convertJAppParametersToCppAppParams(jAppParameters, appParams); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion of AppParameters from jobject to Cpp type failed: %" CHIP_ERROR_FORMAT, - err.Format())); - err = CastingServer::GetInstance()->Init(&appParams); - } - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Call to CastingServer::GetInstance()->Init() failed: %" CHIP_ERROR_FORMAT, err.Format())); -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(void, setDACProvider)(JNIEnv *, jobject, jobject provider) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD setDACProvider called"); - - JNIDACProvider * p = new JNIDACProvider(provider); - chip::Credentials::SetDeviceAttestationCredentialsProvider(p); -} - -JNI_METHOD(jboolean, openBasicCommissioningWindow) -(JNIEnv * env, jobject, jint duration, jobject jCommissioningCallbacks, jobject jOnConnectionSuccessHandler, - jobject jOnConnectionFailureHandler, jobject jOnNewOrUpdatedEndpointHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD openBasicCommissioningWindow called with duration %d", duration); - - CHIP_ERROR err = CHIP_NO_ERROR; - - CommissioningCallbacks commissioningCallbacks; - jclass jCommissioningCallbacksClass; - chip::JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/CommissioningCallbacks", - jCommissioningCallbacksClass); - - jfieldID jCommissioningCompleteField = - env->GetFieldID(jCommissioningCallbacksClass, "commissioningComplete", "Ljava/lang/Object;"); - jobject jCommissioningComplete = env->GetObjectField(jCommissioningCallbacks, jCommissioningCompleteField); - if (jCommissioningComplete != nullptr) - { - err = TvCastingAppJNIMgr().getCommissioningCompleteHandler().SetUp(env, jCommissioningComplete); - VerifyOrReturnValue(err == CHIP_NO_ERROR, false, - ChipLogError(AppServer, "MatterCallbackHandlerJNI::SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - commissioningCallbacks.commissioningComplete = [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getCommissioningCompleteHandler().Handle(err); - }; - } - - jfieldID jSessionEstablishmentStartedField = - env->GetFieldID(jCommissioningCallbacksClass, "sessionEstablishmentStarted", "Lcom/chip/casting/SuccessCallback;"); - jobject jSessionEstablishmentStarted = env->GetObjectField(jCommissioningCallbacks, jSessionEstablishmentStartedField); - if (jSessionEstablishmentStarted != nullptr) - { - err = TvCastingAppJNIMgr().getSessionEstablishmentStartedHandler().SetUp(env, jSessionEstablishmentStarted); - VerifyOrReturnValue( - err == CHIP_NO_ERROR, false, - ChipLogError(AppServer, "SessionEstablishmentStartedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - commissioningCallbacks.sessionEstablishmentStarted = []() { - TvCastingAppJNIMgr().getSessionEstablishmentStartedHandler().Handle(nullptr); - }; - } - - jfieldID jSessionEstablishedField = - env->GetFieldID(jCommissioningCallbacksClass, "sessionEstablished", "Lcom/chip/casting/SuccessCallback;"); - jobject jSessionEstablished = env->GetObjectField(jCommissioningCallbacks, jSessionEstablishedField); - if (jSessionEstablished != nullptr) - { - err = TvCastingAppJNIMgr().getSessionEstablishedHandler().SetUp(env, jSessionEstablished); - VerifyOrReturnValue(err == CHIP_NO_ERROR, false, - ChipLogError(AppServer, "SessionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - commissioningCallbacks.sessionEstablished = []() { TvCastingAppJNIMgr().getSessionEstablishedHandler().Handle(nullptr); }; - } - - jfieldID jSessionEstablishmentErrorField = - env->GetFieldID(jCommissioningCallbacksClass, "sessionEstablishmentError", "Lcom/chip/casting/FailureCallback;"); - jobject jSessionEstablishmentError = env->GetObjectField(jCommissioningCallbacks, jSessionEstablishmentErrorField); - if (jSessionEstablishmentError != nullptr) - { - err = TvCastingAppJNIMgr().getSessionEstablishmentErrorHandler().SetUp(env, jSessionEstablishmentError); - VerifyOrReturnValue(err == CHIP_NO_ERROR, false); - commissioningCallbacks.sessionEstablishmentError = [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getSessionEstablishmentErrorHandler().Handle(err); - }; - } - - jfieldID jSessionEstablishmentStoppedField = - env->GetFieldID(jCommissioningCallbacksClass, "sessionEstablishmentStopped", "Lcom/chip/casting/FailureCallback;"); - jobject jSessionEstablishmentStopped = env->GetObjectField(jCommissioningCallbacks, jSessionEstablishmentStoppedField); - if (jSessionEstablishmentStopped != nullptr) - { - err = TvCastingAppJNIMgr().getSessionEstablishmentStoppedHandler().SetUp(env, jSessionEstablishmentStopped); - VerifyOrReturnValue( - err == CHIP_NO_ERROR, false, - ChipLogError(AppServer, "SessionEstablishmentStoppedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - commissioningCallbacks.sessionEstablishmentStopped = []() { - TvCastingAppJNIMgr().getSessionEstablishmentStoppedHandler().Handle(CHIP_NO_ERROR); - }; - } - - err = TvCastingAppJNIMgr().getOnConnectionSuccessHandler(false).SetUp(env, jOnConnectionSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "OnConnectionSuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getOnConnectionFailureHandler(false).SetUp(env, jOnConnectionFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "OnConnectionFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getOnNewOrUpdatedEndpointHandler(false).SetUp(env, jOnNewOrUpdatedEndpointHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "OnNewOrUpdatedEndpointHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->OpenBasicCommissioningWindow( - commissioningCallbacks, - [](TargetVideoPlayerInfo * videoPlayer) { TvCastingAppJNIMgr().getOnConnectionSuccessHandler(false).Handle(videoPlayer); }, - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getOnConnectionFailureHandler(false).Handle(err); }, - [](TargetEndpointInfo * endpoint) { TvCastingAppJNIMgr().getOnNewOrUpdatedEndpointHandler(false).Handle(endpoint); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer::OpenBasicCommissioningWindow failed: %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jobject, readCachedVideoPlayers)(JNIEnv * env, jobject) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD readCachedVideoPlayers called"); - - jobject jVideoPlayerList = nullptr; - TargetVideoPlayerInfo * targetVideoPlayerInfoList = CastingServer::GetInstance()->ReadCachedTargetVideoPlayerInfos(); - if (targetVideoPlayerInfoList != nullptr) - { - chip::JniReferences::GetInstance().CreateArrayList(jVideoPlayerList); - for (size_t i = 0; targetVideoPlayerInfoList[i].IsInitialized(); i++) - { - jobject jVideoPlayer = nullptr; - CHIP_ERROR err = convertTargetVideoPlayerInfoToJVideoPlayer(&targetVideoPlayerInfoList[i], jVideoPlayer); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, - "Conversion from TargetVideoPlayerInfo * to jobject VideoPlayer failed: %" CHIP_ERROR_FORMAT, - err.Format()); - continue; - } - chip::JniReferences::GetInstance().AddToList(jVideoPlayerList, jVideoPlayer); - } - } - - return jVideoPlayerList; -} - -JNI_METHOD(jboolean, verifyOrEstablishConnection) -(JNIEnv * env, jobject, jobject videoPlayer, jobject jOnConnectionSuccessHandler, jobject jOnConnectionFailureHandler, - jobject jOnNewOrUpdatedEndpointHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD verifyOrEstablishConnection called"); - - TargetVideoPlayerInfo targetVideoPlayerInfo; - CHIP_ERROR err = convertJVideoPlayerToTargetVideoPlayerInfo(videoPlayer, targetVideoPlayerInfo); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, - "Conversion from jobject VideoPlayer to TargetVideoPlayerInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getOnConnectionSuccessHandler(true).SetUp(env, jOnConnectionSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "OnConnectionSuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getOnConnectionFailureHandler(true).SetUp(env, jOnConnectionFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "OnConnectionFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getOnNewOrUpdatedEndpointHandler(true).SetUp(env, jOnNewOrUpdatedEndpointHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "OnNewOrUpdatedEndpointHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->VerifyOrEstablishConnection( - targetVideoPlayerInfo, - [](TargetVideoPlayerInfo * videoPlayer) { TvCastingAppJNIMgr().getOnConnectionSuccessHandler(true).Handle(videoPlayer); }, - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getOnConnectionFailureHandler(true).Handle(err); }, - [](TargetEndpointInfo * endpoint) { TvCastingAppJNIMgr().getOnNewOrUpdatedEndpointHandler(true).Handle(endpoint); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer::verifyOrEstablishConnection failed: %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, WasRecentlyDiscoverable) -(JNIEnv * env, jobject, jobject videoPlayer) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD WasRecentlyDiscoverable called"); - - TargetVideoPlayerInfo targetVideoPlayerInfo; - CHIP_ERROR err = convertJVideoPlayerToTargetVideoPlayerInfo(videoPlayer, targetVideoPlayerInfo); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, - "Conversion from jobject VideoPlayer to TargetVideoPlayerInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - return targetVideoPlayerInfo.WasRecentlyDiscoverable(); - -exit: - return false; // default to false -} - -JNI_METHOD(void, shutdownAllSubscriptions)(JNIEnv * env, jobject) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD shutdownAllSubscriptions called"); - - CastingServer::GetInstance()->ShutdownAllSubscriptions(); -} - -JNI_METHOD(void, disconnect)(JNIEnv * env, jobject) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD disconnect called"); - CastingServer::GetInstance()->Disconnect(); -} - -JNI_METHOD(jobject, getActiveTargetVideoPlayers)(JNIEnv * env, jobject) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD getActiveTargetVideoPlayers called"); - - jobject jVideoPlayerList = nullptr; - TargetVideoPlayerInfo * targetVideoPlayerInfo = CastingServer::GetInstance()->GetActiveTargetVideoPlayer(); - if (targetVideoPlayerInfo != nullptr) - { - chip::JniReferences::GetInstance().CreateArrayList(jVideoPlayerList); - jobject jVideoPlayer = nullptr; - CHIP_ERROR err = convertTargetVideoPlayerInfoToJVideoPlayer(targetVideoPlayerInfo, jVideoPlayer); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Conversion from TargetVideoPlayerInfo * to jobject VideoPlayer failed: %" CHIP_ERROR_FORMAT, - err.Format()); - } - else - { - chip::JniReferences::GetInstance().AddToList(jVideoPlayerList, jVideoPlayer); - } - } - return jVideoPlayerList; -} - -JNI_METHOD(jboolean, sendUserDirectedCommissioningRequest)(JNIEnv * env, jobject, jstring addressJStr, jint port) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD sendUserDirectedCommissioningRequest called with port %d", port); - Inet::IPAddress addressInet; - JniUtfString addressJniString(env, addressJStr); - if (Inet::IPAddress::FromString(addressJniString.c_str(), addressInet) == false) - { - ChipLogError(AppServer, "Failed to parse IP address"); - return false; - } - - chip::Inet::InterfaceId interfaceId = chip::Inet::InterfaceId::FromIPAddress(addressInet); - chip::Transport::PeerAddress peerAddress = - chip::Transport::PeerAddress::UDP(addressInet, static_cast(port), interfaceId); - CHIP_ERROR err = CastingServer::GetInstance()->SendUserDirectedCommissioningRequest(peerAddress); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "TVCastingApp-JNI::sendUserDirectedCommissioningRequest failed: %" CHIP_ERROR_FORMAT, err.Format()); - return false; - } - return true; -} - -JNI_METHOD(jboolean, sendCommissioningRequest)(JNIEnv * env, jobject, jobject jDiscoveredNodeData) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD sendCommissioningRequest called"); - - chip::Dnssd::CommissionNodeData commissioner; - CHIP_ERROR err = convertJDiscoveredNodeDataToCppDiscoveredNodeData(jDiscoveredNodeData, commissioner); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, - "Conversion from jobject DiscoveredNodeData to Cpp DiscoveredNodeData failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = CastingServer::GetInstance()->SendUserDirectedCommissioningRequest(&commissioner); - -exit: - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "TVCastingApp-JNI::sendCommissioningRequest failed: %" CHIP_ERROR_FORMAT, err.Format()); - return false; - } - return true; -} - -JNI_METHOD(jboolean, purgeCache)(JNIEnv * env, jobject) -{ - chip::DeviceLayer::StackLock lock; - ChipLogProgress(AppServer, "JNI_METHOD purgeCache called"); - - CHIP_ERROR err = CastingServer::GetInstance()->PurgeCache(); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "TVCastingApp-JNI::purgeCache failed: %" CHIP_ERROR_FORMAT, err.Format()); - return false; - } - return true; -} - -JNI_METHOD(jboolean, contentLauncherLaunchURL) -(JNIEnv * env, jobject, jobject contentApp, jstring contentUrl, jstring contentDisplayStr, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD contentLauncherLaunchURL called"); - const char * nativeContentUrl = env->GetStringUTFChars(contentUrl, 0); - const char * nativeContentDisplayStr = env->GetStringUTFChars(contentDisplayStr, 0); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(ContentLauncher_LaunchURL).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI::SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ContentLauncherLaunchURL( - &endpoint, nativeContentUrl, nativeContentDisplayStr, - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(ContentLauncher_LaunchURL).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer::ContentLauncherLaunchURL failed %" CHIP_ERROR_FORMAT, err.Format())); - - env->ReleaseStringUTFChars(contentUrl, nativeContentUrl); - env->ReleaseStringUTFChars(contentDisplayStr, nativeContentDisplayStr); - -exit: - return (err == CHIP_NO_ERROR); -} - -CHIP_ERROR CreateParameter(JNIEnv * env, jobject jParameter, - chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & parameter) -{ - jclass jParameterClass = env->GetObjectClass(jParameter); - - jfieldID jTypeField = env->GetFieldID(jParameterClass, "type", "Ljava/lang/Integer;"); - jobject jTypeObj = env->GetObjectField(jParameter, jTypeField); - jclass jIntegerClass = env->FindClass("java/lang/Integer"); - jmethodID jIntValueMid = env->GetMethodID(jIntegerClass, "intValue", "()I"); - parameter.type = static_cast(env->CallIntMethod(jTypeObj, jIntValueMid)); - - jfieldID jValueField = env->GetFieldID(jParameterClass, "value", "Ljava/lang/String;"); - jstring jValueObj = (jstring) env->GetObjectField(jParameter, jValueField); - const char * nativeValue = env->GetStringUTFChars(jValueObj, 0); - parameter.value = CharSpan::fromCharString(nativeValue); - return CHIP_NO_ERROR; -} - -CHIP_ERROR CreateContentSearch(JNIEnv * env, jobject jSearch, - chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & search, - ListFreer & listFreer) -{ - jclass jContentSearchClass; - ReturnErrorOnFailure(JniReferences::GetInstance().GetLocalClassRef(env, "com/chip/casting/ContentLauncherTypes$ContentSearch", - jContentSearchClass)); - - jfieldID jParameterListField = env->GetFieldID(jContentSearchClass, "parameterList", "Ljava/util/ArrayList;"); - jobject jParameterList = env->GetObjectField(jSearch, jParameterListField); - ReturnErrorOnFailure(jParameterList != nullptr ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT); - - jclass jArrayListClass = env->FindClass("java/util/ArrayList"); - jmethodID sizeMid = env->GetMethodID(jArrayListClass, "size", "()I"); - size_t parameterListSize = static_cast(env->CallIntMethod(jParameterList, sizeMid)); - - jobject jIterator = env->CallObjectMethod( - jParameterList, env->GetMethodID(env->GetObjectClass(jParameterList), "iterator", "()Ljava/util/Iterator;")); - jmethodID jNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "next", "()Ljava/lang/Object;"); - jmethodID jHasNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "hasNext", "()Z"); - - auto * parameterListHolder = - new ListHolder(parameterListSize); - listFreer.add(parameterListHolder); - int parameterIndex = 0; - while (env->CallBooleanMethod(jIterator, jHasNextMid)) - { - jobject jParameter = env->CallObjectMethod(jIterator, jNextMid); - chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type parameter; - ReturnErrorOnFailure(CreateParameter(env, jParameter, parameter)); - parameterListHolder->mList[parameterIndex].type = parameter.type; - parameterListHolder->mList[parameterIndex].value = parameter.value; - parameterListHolder->mList[parameterIndex].externalIDList = parameter.externalIDList; - parameterIndex++; - } - search.parameterList = chip::app::DataModel::List( - parameterListHolder->mList, parameterListSize); - - return CHIP_NO_ERROR; -} - -JNI_METHOD(jboolean, contentLauncher_1launchContent) -(JNIEnv * env, jobject, jobject contentApp, jobject jSearch, jboolean jAutoplay, jstring jData, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD contentLauncher_1launchContent called"); - - // prepare arguments - bool autoplay = static_cast(jAutoplay); - - const char * nativeData = env->GetStringUTFChars(jData, 0); - chip::Optional data = MakeOptional(CharSpan::fromCharString(nativeData)); - - ListFreer listFreer; - chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type search; - CHIP_ERROR err = CreateContentSearch(env, jSearch, search, listFreer); - - TargetEndpointInfo endpoint; - err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, - "contentLauncher_1launchContent::Could not create ContentSearch object %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(ContentLauncher_LaunchContent).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI::SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ContentLauncher_LaunchContent(&endpoint, search, autoplay, data, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(ContentLauncher_LaunchContent).Handle(err); - }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer::ContentLauncher_LaunchContent failed %" CHIP_ERROR_FORMAT, err.Format())); - - env->ReleaseStringUTFChars(jData, nativeData); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, contentLauncher_1subscribeToSupportedStreamingProtocols) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD ContentLauncher_subscribeToSupportedStreamingProtocols called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getSupportedStreamingProtocolsSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionReadFailureHandler(ContentLauncher_SupportedStreamingProtocols) - .SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(ContentLauncher_SupportedStreamingProtocols) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ContentLauncher_SubscribeToSupportedStreamingProtocols( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getSupportedStreamingProtocolsSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ContentLauncher_SupportedStreamingProtocols).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(ContentLauncher_SupportedStreamingProtocols).Handle(); - }); - - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, - "CastingServer.ContentLauncher_SubscribeToSupportedStreamingProtocols failed %" CHIP_ERROR_FORMAT, - err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, levelControl_1step) -(JNIEnv * env, jobject, jobject contentApp, jbyte stepMode, jbyte stepSize, jshort transitionTime, jbyte optionMask, - jbyte optionOverride, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD levelControl_step called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(LevelControl_Step).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->LevelControl_Step( - &endpoint, static_cast(stepMode), static_cast(stepSize), - static_cast(transitionTime), static_cast(optionMask), static_cast(optionOverride), - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(LevelControl_Step).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.LevelControl_Step failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, levelControl_1moveToLevel) -(JNIEnv * env, jobject, jobject contentApp, jbyte level, jshort transitionTime, jbyte optionMask, jbyte optionOverride, - jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD levelControl_moveToLevel called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(LevelControl_MoveToLevel).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->LevelControl_MoveToLevel( - &endpoint, static_cast(level), static_cast(transitionTime), static_cast(optionMask), - static_cast(optionOverride), - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(LevelControl_MoveToLevel).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.LevelControl_MoveToLevel failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, levelControl_1subscribeToCurrentLevel) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD levelControl_subscribeToCurrentLevel called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getCurrentLevelSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(LevelControl_CurrentLevel).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(LevelControl_CurrentLevel) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->LevelControl_SubscribeToCurrentLevel( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::LevelControl::Attributes::CurrentLevel::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getCurrentLevelSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(LevelControl_CurrentLevel).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(LevelControl_CurrentLevel).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.LevelControl_SubscribeToCurrentLevel failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, levelControl_1subscribeToMinLevel) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD levelControl_subscribeToMinLevel called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMinLevelSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(LevelControl_MinLevel).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(LevelControl_MinLevel).SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->LevelControl_SubscribeToMinLevel( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::LevelControl::Attributes::MinLevel::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getMinLevelSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(LevelControl_MinLevel).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(LevelControl_MinLevel).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.LevelControl_SubscribeToMinLevel failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, levelControl_1subscribeToMaxLevel) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD levelControl_subscribeToMaxLevel called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMaxLevelSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(LevelControl_MaxLevel).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(LevelControl_MaxLevel).SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->LevelControl_SubscribeToMaxLevel( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::LevelControl::Attributes::MaxLevel::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getMaxLevelSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(LevelControl_MaxLevel).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(LevelControl_MaxLevel).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.LevelControl_SubscribeToMaxLevel failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, onOff_1on) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD onOff_on called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(OnOff_On).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->OnOff_On( - &endpoint, [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(OnOff_On).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "CastingServer.OnOff_On failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, onOff_1off) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD onOff_off called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(OnOff_Off).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->OnOff_Off( - &endpoint, [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(OnOff_Off).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "CastingServer.OnOff_Off failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, onOff_1toggle) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD onOff_toggle called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(OnOff_Toggle).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->OnOff_Toggle( - &endpoint, [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(OnOff_Toggle).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.OnOff_Toggle failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, messages_1presentMessages) -(JNIEnv * env, jobject, jobject contentApp, jstring messageText, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD messages_presentMessages called"); - const char * nativeMessageText = env->GetStringUTFChars(messageText, 0); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(Messages_PresentMessagesRequest).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->Messages_PresentMessagesRequest(&endpoint, nativeMessageText, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(Messages_PresentMessagesRequest).Handle(err); - }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.Messages_PresentMessagesRequest failed %" CHIP_ERROR_FORMAT, err.Format())); - - env->ReleaseStringUTFChars(messageText, nativeMessageText); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1play) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_play called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Play).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_Play( - &endpoint, [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Play).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_Play failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1pause) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_pause called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Pause).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_Pause( - &endpoint, [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Pause).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_Pause failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1stopPlayback) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_stopPlayback called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_StopPlayback).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_StopPlayback(&endpoint, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_StopPlayback).Handle(err); - }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_StopPlayback failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1next) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_next called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Next).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_Next( - &endpoint, [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Next).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_Next failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1seek) -(JNIEnv * env, jobject, jobject contentApp, jlong position, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_seek called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Seek).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_Seek(&endpoint, static_cast(position), [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Seek).Handle(err); - }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_Seek failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1skipForward) -(JNIEnv * env, jobject, jobject contentApp, jlong deltaPositionMilliseconds, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_skipForward called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_SkipForward).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SkipForward( - &endpoint, static_cast(deltaPositionMilliseconds), - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_SkipForward).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_SkipForward failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1skipBackward) -(JNIEnv * env, jobject, jobject contentApp, jlong deltaPositionMilliseconds, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_skipBackward called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_SkipBackward).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SkipBackward( - &endpoint, static_cast(deltaPositionMilliseconds), - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_SkipBackward).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_SkipBackward failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1previous) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - return TvCastingAppJNIMgr().runCastingServerCommand( - env, contentApp, jResponseHandler, "MediaPlayback_Previous", MediaPlayback_Previous, - [](TargetEndpointInfo endpoint) -> CHIP_ERROR { - return CastingServer::GetInstance()->MediaPlayback_Previous(&endpoint, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Previous).Handle(err); - }); - }); -} - -JNI_METHOD(jboolean, mediaPlayback_1rewind) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - return TvCastingAppJNIMgr().runCastingServerCommand( - env, contentApp, jResponseHandler, "MediaPlayback_Rewind", MediaPlayback_Rewind, - [](TargetEndpointInfo endpoint) -> CHIP_ERROR { - return CastingServer::GetInstance()->MediaPlayback_Rewind(&endpoint, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_Rewind).Handle(err); - }); - }); -} - -JNI_METHOD(jboolean, mediaPlayback_1fastForward) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - return TvCastingAppJNIMgr().runCastingServerCommand( - env, contentApp, jResponseHandler, "MediaPlayback_FastForward", MediaPlayback_FastForward, - [](TargetEndpointInfo endpoint) -> CHIP_ERROR { - return CastingServer::GetInstance()->MediaPlayback_FastForward(&endpoint, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_FastForward).Handle(err); - }); - }); -} - -JNI_METHOD(jboolean, mediaPlayback_1startOver) -(JNIEnv * env, jobject, jobject contentApp, jobject jResponseHandler) -{ - return TvCastingAppJNIMgr().runCastingServerCommand( - env, contentApp, jResponseHandler, "MediaPlayback_StartOver", MediaPlayback_StartOver, - [](TargetEndpointInfo endpoint) -> CHIP_ERROR { - return CastingServer::GetInstance()->MediaPlayback_StartOver(&endpoint, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(MediaPlayback_StartOver).Handle(err); - }); - }); -} - -jboolean TvCastingAppJNI::runCastingServerCommand(JNIEnv * env, jobject contentApp, jobject jResponseHandler, - const char * commandName, MediaCommandName command, - const std::function & commandRunner) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD %s called", commandName); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(command).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = commandRunner(endpoint); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.%s failed %" CHIP_ERROR_FORMAT, commandName, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1subscribeToCurrentState) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_subscribeToCurrentState called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getCurrentStateSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_CurrentState).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(MediaPlayback_CurrentState) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SubscribeToCurrentState( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::MediaPlayback::Attributes::CurrentState::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getCurrentStateSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_CurrentState).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(MediaPlayback_CurrentState).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.MediaPlayback_SubscribeToCurrentState failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1subscribeToDuration) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_1subscribeToDuration called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getDurationSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_Duration).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(MediaPlayback_Duration).SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SubscribeToDuration( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::MediaPlayback::Attributes::Duration::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getDurationSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_Duration).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(MediaPlayback_Duration).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.mediaPlayback_subscribeToDuration failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1subscribeToSampledPosition) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_1subscribeToSampledPosition called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getSampledPositionSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_SampledPosition).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(MediaPlayback_SampledPosition) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SubscribeToSampledPosition( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getSampledPositionSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_SampledPosition).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(MediaPlayback_SampledPosition).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.mediaPlayback_subscribeToSampledPosition failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1subscribeToPlaybackSpeed) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_1subscribeToPlaybackSpeed called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getPlaybackSpeedSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_PlaybackSpeed).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(MediaPlayback_PlaybackSpeed) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SubscribeToPlaybackSpeed( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::MediaPlayback::Attributes::PlaybackSpeed::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getPlaybackSpeedSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_PlaybackSpeed).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(MediaPlayback_PlaybackSpeed).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.mediaPlayback_subscribeToPlaybackSpeed failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1subscribeToSeekRangeEnd) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_1subscribeToSeekRangeEnd called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getSeekRangeEndSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_SeekRangeEnd).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(MediaPlayback_SeekRangeEnd) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SubscribeToSeekRangeEnd( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::MediaPlayback::Attributes::SeekRangeEnd::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getSeekRangeEndSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_SeekRangeEnd).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(MediaPlayback_SeekRangeEnd).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.mediaPlayback_subscribeToSeekRangeEnd failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, mediaPlayback_1subscribeToSeekRangeStart) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD mediaPlayback_1subscribeToSeekRangeStart called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getSeekRangeStartSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_SeekRangeStart).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(MediaPlayback_SeekRangeStart) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->MediaPlayback_SubscribeToSeekRangeStart( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::MediaPlayback::Attributes::SeekRangeStart::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getSeekRangeStartSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(MediaPlayback_SeekRangeStart).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(MediaPlayback_SeekRangeStart).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.mediaPlayback_subscribeToSeekRangeStart failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationLauncher_1launchApp) -(JNIEnv * env, jobject, jobject contentApp, jshort catalogVendorId, jstring applicationId, jbyteArray data, - jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationLauncher_launchApp called"); - - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationStruct::Type application; - application.catalogVendorID = static_cast(catalogVendorId); - const char * nativeApplicationId = env->GetStringUTFChars(applicationId, 0); - application.applicationID = CharSpan::fromCharString(nativeApplicationId); - JniByteArray dataByteArray(env, data); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(ApplicationLauncher_LaunchApp).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationLauncher_LaunchApp( - &endpoint, application, chip::MakeOptional(dataByteArray.byteSpan()), - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(ApplicationLauncher_LaunchApp).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.ApplicationLauncher_LaunchApp failed %" CHIP_ERROR_FORMAT, err.Format())); - - env->ReleaseStringUTFChars(applicationId, nativeApplicationId); -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationLauncher_1stopApp) -(JNIEnv * env, jobject, jobject contentApp, jshort catalogVendorId, jstring applicationId, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationLauncher_stopApp called"); - - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationStruct::Type application; - application.catalogVendorID = static_cast(catalogVendorId); - const char * nativeApplicationId = env->GetStringUTFChars(applicationId, 0); - application.applicationID = CharSpan::fromCharString(nativeApplicationId); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(ApplicationLauncher_StopApp).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationLauncher_StopApp(&endpoint, application, [&](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(ApplicationLauncher_StopApp).Handle(err); - }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.ApplicationLauncher_StopApp failed %" CHIP_ERROR_FORMAT, err.Format())); - - env->ReleaseStringUTFChars(applicationId, nativeApplicationId); -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationLauncher_1hideApp) -(JNIEnv * env, jobject, jobject contentApp, jshort catalogVendorId, jstring applicationId, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationLauncher_hideApp called"); - - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationStruct::Type application; - application.catalogVendorID = static_cast(catalogVendorId); - const char * nativeApplicationId = env->GetStringUTFChars(applicationId, 0); - application.applicationID = CharSpan::fromCharString(nativeApplicationId); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(ApplicationLauncher_HideApp).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationLauncher_HideApp(&endpoint, application, [](CHIP_ERROR err) { - TvCastingAppJNIMgr().getMediaCommandResponseHandler(ApplicationLauncher_HideApp).Handle(err); - }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.ApplicationLauncher_HideApp failed %" CHIP_ERROR_FORMAT, err.Format())); - - env->ReleaseStringUTFChars(applicationId, nativeApplicationId); -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, targetNavigator_1navigateTarget) -(JNIEnv * env, jobject, jobject contentApp, jbyte target, jstring data, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD targetNavigator_navigateTarget called"); - - const char * nativeData = (data != nullptr ? env->GetStringUTFChars(data, 0) : nullptr); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(TargetNavigator_NavigateTarget).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->TargetNavigator_NavigateTarget( - &endpoint, static_cast(target), - (nativeData != nullptr ? chip::MakeOptional(CharSpan::fromCharString(nativeData)) : chip::NullOptional), - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(TargetNavigator_NavigateTarget).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.TargetNavigator_NavigateTarget failed %" CHIP_ERROR_FORMAT, err.Format())); - - if (nativeData != nullptr) - { - env->ReleaseStringUTFChars(data, nativeData); - } -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, targetNavigator_1subscribeToCurrentTarget) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD targetNavigator_1subscribeToCurrentTarget called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getCurrentTargetSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(TargetNavigator_CurrentTarget).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(TargetNavigator_CurrentTarget) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->TargetNavigator_SubscribeToCurrentTarget( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getCurrentTargetSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(TargetNavigator_CurrentTarget).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(TargetNavigator_CurrentTarget).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.targetNavigator_subscribeToCurrentTarget failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, targetNavigator_1subscribeToTargetList) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD targetNavigator_1subscribeToTargetList called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getTargetListSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(TargetNavigator_TargetList).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(TargetNavigator_TargetList) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->TargetNavigator_SubscribeToTargetList( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::TargetNavigator::Attributes::TargetList::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getTargetListSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(TargetNavigator_TargetList).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(TargetNavigator_TargetList).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.targetNavigator_subscribeToTargetList failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, keypadInput_1sendKey) -(JNIEnv * env, jobject, jobject contentApp, jbyte keyCode, jobject jResponseHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD keypadInput_sendKey called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getMediaCommandResponseHandler(KeypadInput_SendKey).SetUp(env, jResponseHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->KeypadInput_SendKey( - &endpoint, static_cast(keyCode), - [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(KeypadInput_SendKey).Handle(err); }); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.KeypadInput_SendKey failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -// APPLICATION BASIC -JNI_METHOD(jboolean, applicationBasic_1subscribeToVendorName) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1subscribeToVendorName called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getVendorNameSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_VendorName).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(ApplicationBasic_VendorName) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_SubscribeToVendorName( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getVendorNameSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_VendorName).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(ApplicationBasic_VendorName).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_subscribeToVendorName failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1subscribeToVendorID) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1subscribeToVendorID called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getVendorIDSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_VendorID).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(ApplicationBasic_VendorID) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_SubscribeToVendorID( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getVendorIDSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_VendorID).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(ApplicationBasic_VendorID).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_subscribeToVendorID failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1subscribeToApplicationName) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1subscribeToApplicationName called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getApplicationNameSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_ApplicationName).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(ApplicationBasic_ApplicationName) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_SubscribeToApplicationName( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getApplicationNameSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_ApplicationName).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(ApplicationBasic_ApplicationName).Handle(); - }); - - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_subscribeToApplicationName failed %" CHIP_ERROR_FORMAT, - err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1subscribeToProductID) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1subscribeToProductID called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getProductIDSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_ProductID).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(ApplicationBasic_ProductID) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_SubscribeToProductID( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getProductIDSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_ProductID).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(ApplicationBasic_ProductID).Handle(); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_subscribeToProductID failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1subscribeToApplicationVersion) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler, jint minInterval, - jint maxInterval, jobject jSubscriptionEstablishedHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1subscribeToApplicationVersion called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getApplicationVersionSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_ApplicationVersion).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr() - .getSubscriptionEstablishedHandler(ApplicationBasic_ApplicationVersion) - .SetUp(env, jSubscriptionEstablishedHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "SubscriptionEstablishedHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_SubscribeToApplicationVersion( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getApplicationVersionSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getSubscriptionReadFailureHandler(ApplicationBasic_ApplicationVersion).Handle(err); - }, - static_cast(minInterval), static_cast(maxInterval), - [](void * context, chip::SubscriptionId) { - TvCastingAppJNIMgr().getSubscriptionEstablishedHandler(ApplicationBasic_ApplicationVersion).Handle(); - }); - - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_subscribeToApplicationVersion failed %" CHIP_ERROR_FORMAT, - err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1readVendorName) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readVendorName called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getReadVendorNameSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorName).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_ReadVendorName( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getReadVendorNameSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorName).Handle(err); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_1readVendorName failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1readVendorID) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readVendorID called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getReadVendorIDSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorID).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_ReadVendorID( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::VendorID::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getReadVendorIDSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_VendorID).Handle(err); }); - - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_ReadVendorID failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1readApplicationName) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readApplicationName called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getReadApplicationNameSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationName).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_ReadApplicationName( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getReadApplicationNameSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationName).Handle(err); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_ReadApplicationName failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1readProductID) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readProductID called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getReadProductIDSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ProductID).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_ReadProductID( - &endpoint, nullptr, - [](void * context, chip::app::Clusters::ApplicationBasic::Attributes::ProductID::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getReadProductIDSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ProductID).Handle(err); }); - - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_ReadProductID failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} - -JNI_METHOD(jboolean, applicationBasic_1readApplicationVersion) -(JNIEnv * env, jobject, jobject contentApp, jobject jReadSuccessHandler, jobject jReadFailureHandler) -{ - chip::DeviceLayer::StackLock lock; - - ChipLogProgress(AppServer, "JNI_METHOD applicationBasic_1readApplicationVersion called"); - - TargetEndpointInfo endpoint; - CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); - VerifyOrExit(err == CHIP_NO_ERROR, - ChipLogError(AppServer, "Conversion from jobject contentApp to TargetEndpointInfo * failed: %" CHIP_ERROR_FORMAT, - err.Format())); - - err = TvCastingAppJNIMgr().getReadApplicationVersionSuccessHandler().SetUp(env, jReadSuccessHandler); - VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "SuccessHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationVersion).SetUp(env, jReadFailureHandler); - VerifyOrExit(CHIP_NO_ERROR == err, - ChipLogError(AppServer, "ReadFailureHandler.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); - - err = CastingServer::GetInstance()->ApplicationBasic_ReadApplicationVersion( - &endpoint, nullptr, - [](void * context, - chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo::DecodableArgType responseData) { - TvCastingAppJNIMgr().getReadApplicationVersionSuccessHandler().Handle(responseData); - }, - [](void * context, CHIP_ERROR err) { - TvCastingAppJNIMgr().getReadFailureHandler(ApplicationBasic_ApplicationVersion).Handle(err); - }); - - VerifyOrExit( - CHIP_NO_ERROR == err, - ChipLogError(AppServer, "CastingServer.applicationBasic_ReadApplicationVersion failed %" CHIP_ERROR_FORMAT, err.Format())); - -exit: - return (err == CHIP_NO_ERROR); -} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h deleted file mode 100644 index 863e2691c44a52..00000000000000 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * Copyright (c) 2022 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 "Constants.h" -#include "MatterCallbackHandler-JNI.h" - -class TvCastingAppJNI -{ -public: - MatterCallbackHandlerJNI & getCommissioningCompleteHandler() { return mCommissioningCompleteHandler; } - - SessionEstablishmentStartedHandlerJNI & getSessionEstablishmentStartedHandler() { return mSessionEstablishmentStartedHandler; } - - SessionEstablishedHandlerJNI & getSessionEstablishedHandler() { return mSessionEstablishedHandler; } - - FailureHandlerJNI & getSessionEstablishmentErrorHandler() { return mSessionEstablishmentErrorHandler; } - - FailureHandlerJNI & getSessionEstablishmentStoppedHandler() { return mSessionEstablishmentStoppedHandler; } - - OnConnectionSuccessHandlerJNI & getOnConnectionSuccessHandler(bool preCommissioned) - { - return preCommissioned ? mPreCommissionedOnConnectionSuccessHandler : mCommissioningOnConnectionSuccessHandler; - } - - FailureHandlerJNI & getOnConnectionFailureHandler(bool preCommissioned) - { - return preCommissioned ? mPreCommissionedOnConnectionFailureHandler : mCommissioningOnConnectionFailureHandler; - } - OnNewOrUpdatedEndpointHandlerJNI & getOnNewOrUpdatedEndpointHandler(bool preCommissioned) - { - return preCommissioned ? mPreCommissionedOnNewOrUpdatedEndpointHandler : mCommissioningOnNewOrUpdatedEndpointHandler; - } - - MatterCallbackHandlerJNI & getMediaCommandResponseHandler(enum MediaCommandName name) - { - return mMediaCommandResponseHandler[name]; - } - - FailureHandlerJNI & getReadFailureHandler(enum MediaAttributeName name) { return mReadFailureHandler[name]; } - - FailureHandlerJNI & getSubscriptionReadFailureHandler(enum MediaAttributeName name) - { - return mSubscriptionReadFailureHandler[name]; - } - - SubscriptionEstablishedHandlerJNI & getSubscriptionEstablishedHandler(enum MediaAttributeName name) - { - return mSubscriptionEstablishedHandler[name]; - } - - CurrentStateSuccessHandlerJNI & getCurrentStateSuccessHandler() { return mCurrentStateSuccessHandlerJNI; } - DurationSuccessHandlerJNI & getDurationSuccessHandler() { return mDurationSuccessHandlerJNI; } - SampledPositionSuccessHandlerJNI & getSampledPositionSuccessHandler() { return mSampledPositionSuccessHandlerJNI; } - PlaybackSpeedSuccessHandlerJNI & getPlaybackSpeedSuccessHandler() { return mPlaybackSpeedSuccessHandlerJNI; } - SeekRangeEndSuccessHandlerJNI & getSeekRangeEndSuccessHandler() { return mSeekRangeEndSuccessHandlerJNI; } - SeekRangeStartSuccessHandlerJNI & getSeekRangeStartSuccessHandler() { return mSeekRangeStartSuccessHandlerJNI; } - - CurrentTargetSuccessHandlerJNI & getCurrentTargetSuccessHandler() { return mCurrentTargetSuccessHandlerJNI; } - TargetListSuccessHandlerJNI & getTargetListSuccessHandler() { return mTargetListSuccessHandlerJNI; } - - CurrentLevelSuccessHandlerJNI & getCurrentLevelSuccessHandler() { return mCurrentLevelSuccessHandlerJNI; } - MinLevelSuccessHandlerJNI & getMinLevelSuccessHandler() { return mMinLevelSuccessHandlerJNI; } - MaxLevelSuccessHandlerJNI & getMaxLevelSuccessHandler() { return mMaxLevelSuccessHandlerJNI; } - - SupportedStreamingProtocolsSuccessHandlerJNI & getSupportedStreamingProtocolsSuccessHandler() - { - return mSupportedStreamingProtocolsSuccessHandlerJNI; - } - - VendorNameSuccessHandlerJNI & getVendorNameSuccessHandler() { return mVendorNameSuccessHandlerJNI; } - VendorIDSuccessHandlerJNI & getVendorIDSuccessHandler() { return mVendorIDSuccessHandlerJNI; } - ApplicationNameSuccessHandlerJNI & getApplicationNameSuccessHandler() { return mApplicationNameSuccessHandlerJNI; } - ProductIDSuccessHandlerJNI & getProductIDSuccessHandler() { return mProductIDSuccessHandlerJNI; } - ApplicationVersionSuccessHandlerJNI & getApplicationVersionSuccessHandler() { return mApplicationVersionSuccessHandlerJNI; } - - VendorNameSuccessHandlerJNI & getReadVendorNameSuccessHandler() { return mReadVendorNameSuccessHandlerJNI; } - VendorIDSuccessHandlerJNI & getReadVendorIDSuccessHandler() { return mReadVendorIDSuccessHandlerJNI; } - ApplicationNameSuccessHandlerJNI & getReadApplicationNameSuccessHandler() { return mReadApplicationNameSuccessHandlerJNI; } - ProductIDSuccessHandlerJNI & getReadProductIDSuccessHandler() { return mReadProductIDSuccessHandlerJNI; } - ApplicationVersionSuccessHandlerJNI & getReadApplicationVersionSuccessHandler() - { - return mReadApplicationVersionSuccessHandlerJNI; - } - - jboolean runCastingServerCommand(JNIEnv * env, jobject contentApp, jobject jResponseHandler, const char * commandName, - MediaCommandName command, const std::function & commandRunner); - -private: - friend TvCastingAppJNI & TvCastingAppJNIMgr(); - - static TvCastingAppJNI sInstance; - - MatterCallbackHandlerJNI mCommissioningCompleteHandler; - SessionEstablishmentStartedHandlerJNI mSessionEstablishmentStartedHandler; - SessionEstablishedHandlerJNI mSessionEstablishedHandler; - FailureHandlerJNI mSessionEstablishmentErrorHandler; - FailureHandlerJNI mSessionEstablishmentStoppedHandler; - OnConnectionSuccessHandlerJNI mCommissioningOnConnectionSuccessHandler; - FailureHandlerJNI mCommissioningOnConnectionFailureHandler; - OnNewOrUpdatedEndpointHandlerJNI mCommissioningOnNewOrUpdatedEndpointHandler; - - OnConnectionSuccessHandlerJNI mPreCommissionedOnConnectionSuccessHandler; - FailureHandlerJNI mPreCommissionedOnConnectionFailureHandler; - OnNewOrUpdatedEndpointHandlerJNI mPreCommissionedOnNewOrUpdatedEndpointHandler; - - MatterCallbackHandlerJNI mMediaCommandResponseHandler[MEDIA_COMMAND_COUNT]; - FailureHandlerJNI mSubscriptionReadFailureHandler[MEDIA_ATTRIBUTE_COUNT]; - SubscriptionEstablishedHandlerJNI mSubscriptionEstablishedHandler[MEDIA_ATTRIBUTE_COUNT]; - FailureHandlerJNI mReadFailureHandler[MEDIA_ATTRIBUTE_COUNT]; - - CurrentStateSuccessHandlerJNI mCurrentStateSuccessHandlerJNI; - DurationSuccessHandlerJNI mDurationSuccessHandlerJNI; - SampledPositionSuccessHandlerJNI mSampledPositionSuccessHandlerJNI; - PlaybackSpeedSuccessHandlerJNI mPlaybackSpeedSuccessHandlerJNI; - SeekRangeEndSuccessHandlerJNI mSeekRangeEndSuccessHandlerJNI; - SeekRangeStartSuccessHandlerJNI mSeekRangeStartSuccessHandlerJNI; - - CurrentTargetSuccessHandlerJNI mCurrentTargetSuccessHandlerJNI; - TargetListSuccessHandlerJNI mTargetListSuccessHandlerJNI; - - CurrentLevelSuccessHandlerJNI mCurrentLevelSuccessHandlerJNI; - MinLevelSuccessHandlerJNI mMinLevelSuccessHandlerJNI; - MaxLevelSuccessHandlerJNI mMaxLevelSuccessHandlerJNI; - - SupportedStreamingProtocolsSuccessHandlerJNI mSupportedStreamingProtocolsSuccessHandlerJNI; - - VendorNameSuccessHandlerJNI mVendorNameSuccessHandlerJNI; - VendorIDSuccessHandlerJNI mVendorIDSuccessHandlerJNI; - ApplicationNameSuccessHandlerJNI mApplicationNameSuccessHandlerJNI; - ProductIDSuccessHandlerJNI mProductIDSuccessHandlerJNI; - ApplicationVersionSuccessHandlerJNI mApplicationVersionSuccessHandlerJNI; - - VendorNameSuccessHandlerJNI mReadVendorNameSuccessHandlerJNI; - VendorIDSuccessHandlerJNI mReadVendorIDSuccessHandlerJNI; - ApplicationNameSuccessHandlerJNI mReadApplicationNameSuccessHandlerJNI; - ProductIDSuccessHandlerJNI mReadProductIDSuccessHandlerJNI; - ApplicationVersionSuccessHandlerJNI mReadApplicationVersionSuccessHandlerJNI; -}; - -inline class TvCastingAppJNI & TvCastingAppJNIMgr() -{ - return TvCastingAppJNI::sInstance; -} diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp index ce8e8c0e1b77a6..2242619df27431 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingApp-JNI.cpp @@ -18,8 +18,8 @@ #include "CastingApp-JNI.h" -#include "../JNIDACProvider.h" #include "../support/Converters-JNI.h" +#include "../support/JNIDACProvider.h" #include "../support/RotatingDeviceIdUniqueIdProvider-JNI.h" // from tv-casting-common @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,16 @@ using namespace chip; #define JNI_METHOD(RETURN, METHOD_NAME) extern "C" JNIEXPORT RETURN JNICALL Java_com_matter_casting_core_CastingApp_##METHOD_NAME +jint JNI_OnLoad(JavaVM * jvm, void * reserved) +{ + return AndroidAppServerJNI_OnLoad(jvm, reserved); +} + +void JNI_OnUnload(JavaVM * jvm, void * reserved) +{ + return AndroidAppServerJNI_OnUnload(jvm, reserved); +} + namespace matter { namespace casting { namespace core { @@ -73,7 +84,7 @@ JNI_METHOD(jobject, finishInitialization)(JNIEnv *, jobject, jobject jAppParamet VerifyOrReturnValue(jDACProvider != nullptr, support::convertMatterErrorFromCppToJava(CHIP_ERROR_INCORRECT_STATE)); // set the DACProvider - JNIDACProvider * dacProvider = new JNIDACProvider(jDACProvider); + support::JNIDACProvider * dacProvider = new support::JNIDACProvider(jDACProvider); chip::Credentials::SetDeviceAttestationCredentialsProvider(dacProvider); return support::convertMatterErrorFromCppToJava(CHIP_NO_ERROR); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayerDiscovery-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayerDiscovery-JNI.cpp index 26526dfdac8f07..0dd0a351b7a679 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayerDiscovery-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/CastingPlayerDiscovery-JNI.cpp @@ -18,7 +18,6 @@ #include "CastingPlayerDiscovery-JNI.h" -#include "../JNIDACProvider.h" #include "../support/Converters-JNI.h" #include "../support/RotatingDeviceIdUniqueIdProvider-JNI.h" #include "core/CastingApp.h" // from tv-casting-common diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterCastingPlayer-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterCastingPlayer-JNI.cpp index b718682a17124b..5219dbca3a88af 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterCastingPlayer-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterCastingPlayer-JNI.cpp @@ -18,7 +18,6 @@ #include "MatterCastingPlayer-JNI.h" -#include "../JNIDACProvider.h" #include "../support/Converters-JNI.h" #include "../support/RotatingDeviceIdUniqueIdProvider-JNI.h" #include "core/CastingApp.h" // from tv-casting-common diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterEndpoint-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterEndpoint-JNI.cpp index e0c41ebc92d260..685be549856981 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterEndpoint-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterEndpoint-JNI.cpp @@ -18,7 +18,6 @@ #include "MatterEndpoint-JNI.h" -#include "../JNIDACProvider.h" #include "../support/MatterCallback-JNI.h" #include "../support/RotatingDeviceIdUniqueIdProvider-JNI.h" #include "clusters/Clusters.h" // from tv-casting-common diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/JNIDACProvider.cpp similarity index 98% rename from examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.cpp rename to examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/JNIDACProvider.cpp index 363a629db2c9e5..1fbbfd1402dda8 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/JNIDACProvider.cpp @@ -29,6 +29,10 @@ using namespace chip; +namespace matter { +namespace casting { +namespace support { + JNIDACProvider::JNIDACProvider(jobject provider) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -174,3 +178,7 @@ CHIP_ERROR JNIDACProvider::SignWithDeviceAttestationKey(const ByteSpan & message return chip::Crypto::EcdsaAsn1SignatureToRaw(32, ByteSpan(asn1_signature_buffer.data(), asn1_signature_buffer.size()), out_signature_buffer); } + +}; // namespace support +}; // namespace casting +}; // namespace matter diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/JNIDACProvider.h similarity index 94% rename from examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.h rename to examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/JNIDACProvider.h index d8d774f41f3061..bb7902f600848c 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.h +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/JNIDACProvider.h @@ -21,6 +21,10 @@ #include #include +namespace matter { +namespace casting { +namespace support { + class JNIDACProvider : public chip::Credentials::DeviceAttestationCredentialsProvider { public: @@ -42,3 +46,7 @@ class JNIDACProvider : public chip::Credentials::DeviceAttestationCredentialsPro jmethodID mGetProductAttestationIntermediateCertMethod = nullptr; jmethodID mSignWithDeviceAttestationKeyMethod = nullptr; }; + +}; // namespace support +}; // namespace casting +}; // namespace matter diff --git a/examples/tv-casting-app/android/App/app/src/main/res/layout/activity_main.xml b/examples/tv-casting-app/android/App/app/src/main/res/layout/activity_main.xml index ff56873cb23c22..8e3724ec39dd48 100644 --- a/examples/tv-casting-app/android/App/app/src/main/res/layout/activity_main.xml +++ b/examples/tv-casting-app/android/App/app/src/main/res/layout/activity_main.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".chip.casting.app.MainActivity"> + tools:context=".matter.casting.MainActivity"> ShutdownAllSubscriptions(); return CHIP_NO_ERROR; diff --git a/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter b/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter index 135846fd606d48..3c20256117f2cb 100644 --- a/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter +++ b/examples/virtual-device-app/virtual-device-common/virtual-device-app.matter @@ -3161,65 +3161,62 @@ cluster WindowCovering = 258 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -3230,16 +3227,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -3271,13 +3279,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -3291,150 +3299,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index d85e82fec6fa6c..aef22e030eae8d 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -157,7 +157,7 @@ def _GetInDevelopmentTests() -> Set[str]: # TestEventTriggersEnabled is true, which it's not in CI. "Test_TC_SMOKECO_2_6.yaml", # chip-repl does not support local timeout (07/20/2023) and test assumes # TestEventTriggersEnabled is true, which it's not in CI. - "TestFabricSyncBridgedNode.yaml", # [TODO] fabric-bridge-app lacks some feature so this test currently fails + "Test_TC_BR_5.yaml", # [TODO] Fabric Sync example app has not been integrated into CI yet. } diff --git a/src/app/CommandHandlerInterfaceRegistry.cpp b/src/app/CommandHandlerInterfaceRegistry.cpp index 01436853dd1a55..8345be5dcc2805 100644 --- a/src/app/CommandHandlerInterfaceRegistry.cpp +++ b/src/app/CommandHandlerInterfaceRegistry.cpp @@ -68,8 +68,11 @@ void CommandHandlerInterfaceRegistry::UnregisterAllCommandHandlersForEndpoint(En { CommandHandlerInterface * prev = nullptr; - for (auto * cur = mCommandHandlerList; cur; cur = cur->GetNext()) + for (auto * cur = mCommandHandlerList; cur;) { + // Fetch next node in the list before we remove this one. + auto * next = cur->GetNext(); + if (cur->MatchesEndpoint(endpointId)) { if (prev == nullptr) @@ -87,6 +90,8 @@ void CommandHandlerInterfaceRegistry::UnregisterAllCommandHandlersForEndpoint(En { prev = cur; } + + cur = next; } } diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index 4a4fc69b4efe07..406d06f4b1e794 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -35,31 +36,6 @@ using namespace chip::app::Clusters; using namespace chip::app::Clusters::ColorControl; using chip::Protocols::InteractionModel::Status; -// These constants are NOT currently spec compliant -// These should be changed once we have real specification enumeration -// names. -namespace chip { -namespace app { -namespace Clusters { -namespace ColorControl { - -namespace EnhancedColorMode { -constexpr uint8_t kCurrentHueAndCurrentSaturation = ColorControlServer::EnhancedColorMode::kCurrentHueAndCurrentSaturation; -constexpr uint8_t kCurrentXAndCurrentY = ColorControlServer::EnhancedColorMode::kCurrentXAndCurrentY; -constexpr uint8_t kColorTemperature = ColorControlServer::EnhancedColorMode::kColorTemperature; -constexpr uint8_t kEnhancedCurrentHueAndCurrentSaturation = - ColorControlServer::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation; -} // namespace EnhancedColorMode - -namespace Options { -constexpr uint8_t kExecuteIfOff = 1; -} // namespace Options - -} // namespace ColorControl -} // namespace Clusters -} // namespace app -} // namespace chip - #if defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl { @@ -174,12 +150,12 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl AddAttributeValuePair(pairs, Attributes::ColorTemperatureMireds::Id, temperatureValue, attributeCount); } - uint8_t modeValue; + EnhancedColorMode modeValue; if (Status::Success != Attributes::EnhancedColorMode::Get(endpoint, &modeValue)) { - modeValue = ColorControl::EnhancedColorMode::kCurrentXAndCurrentY; // Default mode value according to spec + modeValue = EnhancedColorMode::kCurrentXAndCurrentY; // Default mode value according to spec } - AddAttributeValuePair(pairs, Attributes::EnhancedColorMode::Id, modeValue, attributeCount); + AddAttributeValuePair(pairs, Attributes::EnhancedColorMode::Id, to_underlying(modeValue), attributeCount); app::DataModel::List attributeValueList(pairs, attributeCount); @@ -226,7 +202,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl #endif // Initialize action attributes to default values in case they are not in the scene - uint8_t targetColorMode = 0x00; + auto targetColorMode = EnhancedColorModeEnum::kCurrentHueAndCurrentSaturation; uint8_t loopActiveValue = 0x00; uint8_t loopDirectionValue = 0x00; uint16_t loopTimeValue = 0x0019; // Default loop time value according to spec @@ -238,7 +214,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl switch (decodePair.attributeID) { case Attributes::CurrentX::Id: - if (SupportsColorMode(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY)) + if (SupportsColorMode(endpoint, EnhancedColorMode::kCurrentXAndCurrentY)) { VerifyOrReturnError(decodePair.valueUnsigned16.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); colorXTransitionState->finalValue = @@ -246,7 +222,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl } break; case Attributes::CurrentY::Id: - if (SupportsColorMode(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY)) + if (SupportsColorMode(endpoint, EnhancedColorMode::kCurrentXAndCurrentY)) { VerifyOrReturnError(decodePair.valueUnsigned16.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); colorYTransitionState->finalValue = @@ -254,14 +230,14 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl } break; case Attributes::EnhancedCurrentHue::Id: - if (SupportsColorMode(endpoint, ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation)) + if (SupportsColorMode(endpoint, EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation)) { VerifyOrReturnError(decodePair.valueUnsigned16.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); colorHueTransitionState->finalEnhancedHue = decodePair.valueUnsigned16.Value(); } break; case Attributes::CurrentSaturation::Id: - if (SupportsColorMode(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation)) + if (SupportsColorMode(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation)) { VerifyOrReturnError(decodePair.valueUnsigned8.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); colorSaturationTransitionState->finalValue = std::min(static_cast(decodePair.valueUnsigned8.Value()), @@ -281,7 +257,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl loopTimeValue = decodePair.valueUnsigned16.Value(); break; case Attributes::ColorTemperatureMireds::Id: - if (SupportsColorMode(endpoint, ColorControl::EnhancedColorMode::kColorTemperature)) + if (SupportsColorMode(endpoint, EnhancedColorMode::kColorTemperatureMireds)) { VerifyOrReturnError(decodePair.valueUnsigned16.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); colorTempTransitionState->finalValue = @@ -290,10 +266,9 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl break; case Attributes::EnhancedColorMode::Id: VerifyOrReturnError(decodePair.valueUnsigned8.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); - if (decodePair.valueUnsigned8.Value() <= - static_cast(ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation)) + if (decodePair.valueUnsigned8.Value() <= to_underlying(EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation)) { - targetColorMode = decodePair.valueUnsigned8.Value(); + targetColorMode = static_cast(decodePair.valueUnsigned8.Value()); } break; default: @@ -328,25 +303,25 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl // Execute movement to value depending on the mode in the saved scene switch (targetColorMode) { - case ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation: + case EnhancedColorMode::kCurrentHueAndCurrentSaturation: #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_HSV ColorControlServer::Instance().moveToSaturation(static_cast(colorSaturationTransitionState->finalValue), transitionTime10th, endpoint); #endif // MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_HSV break; - case ColorControl::EnhancedColorMode::kCurrentXAndCurrentY: + case EnhancedColorMode::kCurrentXAndCurrentY: #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_XY ColorControlServer::Instance().moveToColor(colorXTransitionState->finalValue, colorYTransitionState->finalValue, transitionTime10th, endpoint); #endif // MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_XY break; - case ColorControl::EnhancedColorMode::kColorTemperature: + case EnhancedColorMode::kColorTemperatureMireds: #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_TEMP ColorControlServer::Instance().moveToColorTemp( endpoint, static_cast(colorTempTransitionState->finalValue), transitionTime10th); #endif // MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_TEMP break; - case ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation: + case EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation: #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_HSV ColorControlServer::Instance().moveToHueAndSaturation( colorHueTransitionState->finalEnhancedHue, static_cast(colorSaturationTransitionState->finalValue), @@ -361,20 +336,20 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl } private: - bool SupportsColorMode(EndpointId endpoint, uint8_t mode) + bool SupportsColorMode(EndpointId endpoint, EnhancedColorMode mode) { switch (mode) { - case ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation: + case EnhancedColorMode::kCurrentHueAndCurrentSaturation: return ColorControlServer::Instance().HasFeature(endpoint, ColorControlServer::Feature::kHueAndSaturation); break; - case ColorControl::EnhancedColorMode::kCurrentXAndCurrentY: + case EnhancedColorMode::kCurrentXAndCurrentY: return ColorControlServer::Instance().HasFeature(endpoint, ColorControlServer::Feature::kXy); break; - case ColorControl::EnhancedColorMode::kColorTemperature: + case EnhancedColorMode::kColorTemperatureMireds: return ColorControlServer::Instance().HasFeature(endpoint, ColorControlServer::Feature::kColorTemperature); break; - case ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation: + case EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation: return ColorControlServer::Instance().HasFeature(endpoint, ColorControlServer::Feature::kEnhancedHue); break; default: @@ -494,7 +469,7 @@ Status ColorControlServer::stopAllColorTransitions(EndpointId endpoint) } bool ColorControlServer::stopMoveStepCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - uint8_t optionsMask, uint8_t optionsOverride) + BitMask optionsMask, BitMask optionsOverride) { EndpointId endpoint = commandPath.mEndpointId; Status status = Status::Success; @@ -534,7 +509,8 @@ bool ColorControlServer::stopMoveStepCommand(app::CommandHandler * commandObj, c return true; } -bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionMask, uint8_t optionOverride) +bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, BitMask optionMask, + BitMask optionOverride) { // From 5.2.2.2.1.10 of ZCL7 document 14-0129-15f-zcl-ch-5-lighting.docx: // "Command execution SHALL NOT continue beyond the Options processing if @@ -549,7 +525,7 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM return true; } - uint8_t options = 0x00; + BitMask options = 0x00; Attributes::Options::Get(endpoint, &options); bool on = true; @@ -576,23 +552,23 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM // ---------- The following order is important in decision making ------- // -----------more readable ---------- // - if (optionMask == 0xFF && optionOverride == 0xFF) + if (optionMask == static_cast(0xFF) && optionOverride == static_cast(0xFF)) { // 0xFF are the default values passed to the command handler when // the payload is not present - in that case there is use of option // attribute to decide execution of the command - return READBITS(options, ColorControl::Options::kExecuteIfOff); + return options.Has(OptionsBitmap::kExecuteIfOff); } // ---------- The above is to distinguish if the payload is present or not - if (READBITS(optionMask, ColorControl::Options::kExecuteIfOff)) + if (optionMask.Has(OptionsBitmap::kExecuteIfOff)) { // Mask is present and set in the command payload, this indicates // use the override as temporary option - return READBITS(optionOverride, ColorControl::Options::kExecuteIfOff); + return optionOverride.Has(OptionsBitmap::kExecuteIfOff); } - // if we are here - use the option attribute bits - return (READBITS(options, ColorControl::Options::kExecuteIfOff)); + // if we are here - use the option bits + return options.Has(OptionsBitmap::kExecuteIfOff); } /** @@ -606,28 +582,28 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM * @param endpoint * @param newColorMode */ -void ColorControlServer::handleModeSwitch(EndpointId endpoint, uint8_t newColorMode) +void ColorControlServer::handleModeSwitch(EndpointId endpoint, EnhancedColorModeEnum newColorMode) { - uint8_t oldColorMode = 0; + auto oldColorMode = ColorModeEnum::kCurrentHueAndCurrentSaturation; Attributes::ColorMode::Get(endpoint, &oldColorMode); uint8_t colorModeTransition; - if (oldColorMode == newColorMode) + if (static_cast(oldColorMode) == newColorMode) { return; } Attributes::EnhancedColorMode::Set(endpoint, newColorMode); - if (newColorMode == ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation) + if (newColorMode == EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation) { - // Transpose COLOR_MODE_EHSV to ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation after setting + // Transpose COLOR_MODE_EHSV to EnhancedColorMode::kCurrentHueAndCurrentSaturation after setting // EnhancedColorMode - newColorMode = ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation; + newColorMode = EnhancedColorMode::kCurrentHueAndCurrentSaturation; } - Attributes::ColorMode::Set(endpoint, newColorMode); + Attributes::ColorMode::Set(endpoint, static_cast(newColorMode)); - colorModeTransition = static_cast((newColorMode << 4) + oldColorMode); + colorModeTransition = static_cast((to_underlying(newColorMode) << 4) + to_underlying(oldColorMode)); // Note: It may be OK to not do anything here. switch (colorModeTransition) @@ -1044,7 +1020,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt colorHueTransitionState->initialEnhancedHue = startHue; - if (direction == to_underlying(ColorLoopDirection::kIncrementHue)) + if (direction == to_underlying(ColorLoopDirectionEnum::kIncrement)) { colorHueTransitionState->finalEnhancedHue = static_cast(startHue - 1); } @@ -1053,7 +1029,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt colorHueTransitionState->finalEnhancedHue = static_cast(startHue + 1); } - colorHueTransitionState->up = (direction == to_underlying(ColorLoopDirection::kIncrementHue)); + colorHueTransitionState->up = (direction == to_underlying(ColorLoopDirectionEnum::kIncrement)); colorHueTransitionState->repeat = true; colorHueTransitionState->stepsRemaining = static_cast(time * TRANSITION_STEPS_PER_1S); @@ -1297,7 +1273,7 @@ Status ColorControlServer::moveToSaturation(uint8_t saturation, uint16_t transit stopAllColorTransitions(endpoint); // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation); // now, kick off the state machine. initSaturationTransitionState(endpoint, colorSaturationTransitionState); @@ -1421,8 +1397,8 @@ Status ColorControlServer::moveToHueAndSaturation(uint16_t hue, uint8_t saturati * @return false Failed */ bool ColorControlServer::moveHueCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - HueMoveMode moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride, - bool isEnhanced) + HueMoveMode moveMode, uint16_t rate, BitMask optionsMask, + BitMask optionsOverride, bool isEnhanced) { MATTER_TRACE_SCOPE("moveHue", "ColorControl"); EndpointId endpoint = commandPath.mEndpointId; @@ -1464,11 +1440,11 @@ bool ColorControlServer::moveHueCommand(app::CommandHandler * commandObj, const // Handle color mode transition, if necessary. if (isEnhanced) { - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); } else { - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation); } if (moveMode == HueMoveMode::kUp) @@ -1531,15 +1507,16 @@ bool ColorControlServer::moveHueCommand(app::CommandHandler * commandObj, const * @return false Failed */ bool ColorControlServer::moveToHueCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - uint16_t hue, HueDirection moveDirection, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride, bool isEnhanced) + uint16_t hue, DirectionEnum moveDirection, uint16_t transitionTime, + BitMask optionsMask, BitMask optionsOverride, + bool isEnhanced) { MATTER_TRACE_SCOPE("moveToHue", "ColorControl"); EndpointId endpoint = commandPath.mEndpointId; Status status = Status::Success; uint16_t currentHue = 0; - HueDirection direction; + DirectionEnum direction; ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); @@ -1568,33 +1545,33 @@ bool ColorControlServer::moveToHueCommand(app::CommandHandler * commandObj, cons // Convert the ShortestDistance/LongestDistance moveDirection values into Up/Down. switch (moveDirection) { - case HueDirection::kShortestDistance: + case DirectionEnum::kShortest: if ((isEnhanced && (static_cast(currentHue - hue) > HALF_MAX_UINT16T)) || (!isEnhanced && (static_cast(currentHue - hue) > HALF_MAX_UINT8T))) { - direction = HueDirection::kUp; + direction = DirectionEnum::kUp; } else { - direction = HueDirection::kDown; + direction = DirectionEnum::kDown; } break; - case HueDirection::kLongestDistance: + case DirectionEnum::kLongest: if ((isEnhanced && (static_cast(currentHue - hue) > HALF_MAX_UINT16T)) || (!isEnhanced && (static_cast(currentHue - hue) > HALF_MAX_UINT8T))) { - direction = HueDirection::kDown; + direction = DirectionEnum::kDown; } else { - direction = HueDirection::kUp; + direction = DirectionEnum::kUp; } break; - case HueDirection::kUp: - case HueDirection::kDown: + case DirectionEnum::kUp: + case DirectionEnum::kDown: direction = moveDirection; break; - case HueDirection::kUnknownEnumValue: + case DirectionEnum::kUnknownEnumValue: commandObj->AddStatus(commandPath, Status::InvalidCommand); return true; /* No default case, so if a new direction value gets added we will just fail @@ -1613,11 +1590,11 @@ bool ColorControlServer::moveToHueCommand(app::CommandHandler * commandObj, cons // Handle color mode transition, if necessary. if (isEnhanced) { - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); } else { - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation); } // now, kick off the state machine. @@ -1637,7 +1614,7 @@ bool ColorControlServer::moveToHueCommand(app::CommandHandler * commandObj, cons colorHueTransitionState->timeRemaining = transitionTime; colorHueTransitionState->transitionTime = transitionTime; colorHueTransitionState->endpoint = endpoint; - colorHueTransitionState->up = (direction == HueDirection::kUp); + colorHueTransitionState->up = (direction == DirectionEnum::kUp); colorHueTransitionState->repeat = false; SetHSVRemainingTime(endpoint); @@ -1667,8 +1644,9 @@ bool ColorControlServer::moveToHueCommand(app::CommandHandler * commandObj, cons */ bool ColorControlServer::moveToHueAndSaturationCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, uint16_t hue, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride, bool isEnhanced) + uint8_t saturation, uint16_t transitionTime, + BitMask optionsMask, BitMask optionsOverride, + bool isEnhanced) { MATTER_TRACE_SCOPE("moveToHueAndSaturation", "ColorControl"); // limit checking: hue and saturation are 0..254. Spec dictates we ignore @@ -1707,8 +1685,8 @@ bool ColorControlServer::moveToHueAndSaturationCommand(app::CommandHandler * com * @return false Failed */ bool ColorControlServer::stepHueCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - HueStepMode stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride, bool isEnhanced) + HueStepMode stepMode, uint16_t stepSize, uint16_t transitionTime, + BitMask optionsMask, BitMask optionsOverride, bool isEnhanced) { MATTER_TRACE_SCOPE("stepHue", "ColorControl"); EndpointId endpoint = commandPath.mEndpointId; @@ -1737,11 +1715,11 @@ bool ColorControlServer::stepHueCommand(app::CommandHandler * commandObj, const // Handle color mode transition, if necessary. if (isEnhanced) { - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); } else { - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation); } // now, kick off the state machine. @@ -1839,7 +1817,7 @@ bool ColorControlServer::moveSaturationCommand(app::CommandHandler * commandObj, } // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation); if (moveMode == SaturationMoveMode::kUp) { @@ -1908,14 +1886,14 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj, const Commands::StepSaturation::DecodableType & commandData) { MATTER_TRACE_SCOPE("stepSaturation", "ColorControl"); - auto stepMode = commandData.stepMode; - uint8_t stepSize = commandData.stepSize; - uint8_t transitionTime = commandData.transitionTime; - uint8_t optionsMask = commandData.optionsMask; - uint8_t optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - Status status = Status::Success; - uint8_t currentSaturation = 0; + auto stepMode = commandData.stepMode; + uint8_t stepSize = commandData.stepSize; + uint8_t transitionTime = commandData.transitionTime; + BitMask optionsMask = commandData.optionsMask; + BitMask optionsOverride = commandData.optionsOverride; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; + uint8_t currentSaturation = 0; Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint); @@ -1937,7 +1915,7 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj, stopAllColorTransitions(endpoint); // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation); // now, kick off the state machine. initSaturationTransitionState(endpoint, colorSaturationTransitionState); @@ -1973,24 +1951,24 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons const Commands::ColorLoopSet::DecodableType & commandData) { MATTER_TRACE_SCOPE("colorLoop", "ColorControl"); - auto updateFlags = commandData.updateFlags; - auto action = commandData.action; - auto direction = commandData.direction; - uint16_t time = commandData.time; - uint16_t startHue = commandData.startHue; - uint8_t optionsMask = commandData.optionsMask; - uint8_t optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - Status status = Status::Success; - uint8_t isColorLoopActive = 0; - uint8_t deactiveColorLoop = 0; + auto updateFlags = commandData.updateFlags; + auto action = commandData.action; + auto direction = commandData.direction; + uint16_t time = commandData.time; + uint16_t startHue = commandData.startHue; + BitMask optionsMask = commandData.optionsMask; + BitMask optionsOverride = commandData.optionsOverride; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; + uint8_t isColorLoopActive = 0; + uint8_t deactiveColorLoop = 0; uint16_t epIndex = getEndpointIndex(endpoint); ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionStateByIndex(epIndex); VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint); // Validate the action and direction parameters of the command - if (action == ColorLoopAction::kUnknownEnumValue || direction == ColorLoopDirection::kUnknownEnumValue) + if (action == ColorLoopActionEnum::kUnknownEnumValue || direction == ColorLoopDirectionEnum::kUnknownEnumValue) { commandObj->AddStatus(commandPath, Status::InvalidCommand); return true; @@ -2017,10 +1995,10 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons // Checks if color loop is active and stays active if (isColorLoopActive && !deactiveColorLoop) { - colorHueTransitionState->up = (direction == ColorLoopDirection::kIncrementHue); + colorHueTransitionState->up = (direction == ColorLoopDirectionEnum::kIncrement); colorHueTransitionState->initialEnhancedHue = colorHueTransitionState->currentEnhancedHue; - if (direction == ColorLoopDirection::kIncrementHue) + if (direction == ColorLoopDirectionEnum::kIncrement) { colorHueTransitionState->finalEnhancedHue = static_cast(colorHueTransitionState->initialEnhancedHue - 1); } @@ -2346,12 +2324,12 @@ bool ColorControlServer::moveToColorCommand(app::CommandHandler * commandObj, co bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveColor::DecodableType & commandData) { - int16_t rateX = commandData.rateX; - int16_t rateY = commandData.rateY; - uint8_t optionsMask = commandData.optionsMask; - uint8_t optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - Status status = Status::Success; + int16_t rateX = commandData.rateX; + int16_t rateY = commandData.rateY; + BitMask optionsMask = commandData.optionsMask; + BitMask optionsOverride = commandData.optionsOverride; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; uint16_t epIndex = getEndpointIndex(endpoint); Color16uTransitionState * colorXTransitionState = getXTransitionStateByIndex(epIndex); @@ -2380,7 +2358,7 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons } // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentXAndCurrentY); // now, kick off the state machine. Attributes::CurrentX::Get(endpoint, &(colorXTransitionState->initialValue)); @@ -2438,16 +2416,16 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons bool ColorControlServer::stepColorCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepColor::DecodableType & commandData) { - int16_t stepX = commandData.stepX; - int16_t stepY = commandData.stepY; - uint16_t transitionTime = commandData.transitionTime; - uint8_t optionsMask = commandData.optionsMask; - uint8_t optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - uint16_t currentColorX = 0; - uint16_t currentColorY = 0; - uint16_t colorX = 0; - uint16_t colorY = 0; + int16_t stepX = commandData.stepX; + int16_t stepY = commandData.stepY; + uint16_t transitionTime = commandData.transitionTime; + BitMask optionsMask = commandData.optionsMask; + BitMask optionsOverride = commandData.optionsOverride; + EndpointId endpoint = commandPath.mEndpointId; + uint16_t currentColorX = 0; + uint16_t currentColorY = 0; + uint16_t colorX = 0; + uint16_t colorY = 0; Status status = Status::Success; @@ -2480,7 +2458,7 @@ bool ColorControlServer::stepColorCommand(app::CommandHandler * commandObj, cons stopAllColorTransitions(endpoint); // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY); + handleModeSwitch(endpoint, EnhancedColorMode::kCurrentXAndCurrentY); // now, kick off the state machine. colorXTransitionState->initialValue = currentColorX; @@ -2615,7 +2593,7 @@ Status ColorControlServer::moveToColorTemp(EndpointId aEndpoint, uint16_t colorT stopAllColorTransitions(endpoint); // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kColorTemperature); + handleModeSwitch(endpoint, EnhancedColorMode::kColorTemperatureMireds); if (colorTemperature < temperatureMin) { @@ -2724,11 +2702,10 @@ void ColorControlServer::startUpColorTempCommand(EndpointId endpoint) if (status == Status::Success) { // Set ColorMode attributes to reflect ColorTemperature. - uint8_t updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature; + auto updateColorMode = ColorModeEnum::kColorTemperatureMireds; Attributes::ColorMode::Set(endpoint, updateColorMode); - updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature; - Attributes::EnhancedColorMode::Set(endpoint, updateColorMode); + Attributes::EnhancedColorMode::Set(endpoint, static_cast(updateColorMode)); } } } @@ -2798,16 +2775,16 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint) bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveColorTemperature::DecodableType & commandData) { - auto moveMode = commandData.moveMode; - uint16_t rate = commandData.rate; - uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; - uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; - uint8_t optionsMask = commandData.optionsMask; - uint8_t optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - Status status = Status::Success; - uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; - uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; + auto moveMode = commandData.moveMode; + uint16_t rate = commandData.rate; + uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; + uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; + BitMask optionsMask = commandData.optionsMask; + BitMask optionsOverride = commandData.optionsOverride; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; + uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; + uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; uint16_t transitionTime; Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); @@ -2854,7 +2831,7 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, } // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kColorTemperature); + handleModeSwitch(endpoint, EnhancedColorMode::kColorTemperatureMireds); // now, kick off the state machine. colorTempTransitionState->initialValue = 0; @@ -2922,17 +2899,17 @@ bool ColorControlServer::moveToColorTempCommand(app::CommandHandler * commandObj bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepColorTemperature::DecodableType & commandData) { - auto stepMode = commandData.stepMode; - uint16_t stepSize = commandData.stepSize; - uint16_t transitionTime = commandData.transitionTime; - uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; - uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; - uint8_t optionsMask = commandData.optionsMask; - uint8_t optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - Status status = Status::Success; - uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; - uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; + auto stepMode = commandData.stepMode; + uint16_t stepSize = commandData.stepSize; + uint16_t transitionTime = commandData.transitionTime; + uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; + uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; + BitMask optionsMask = commandData.optionsMask; + BitMask optionsOverride = commandData.optionsOverride; + EndpointId endpoint = commandPath.mEndpointId; + Status status = Status::Success; + uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; + uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint); @@ -2971,7 +2948,7 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, } // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kColorTemperature); + handleModeSwitch(endpoint, EnhancedColorMode::kColorTemperatureMireds); // now, kick off the state machine. colorTempTransitionState->initialValue = 0; @@ -3058,10 +3035,10 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint) return; } - uint8_t colorMode = 0; + auto colorMode = ColorModeEnum::kCurrentHueAndCurrentSaturation; Attributes::ColorMode::Get(endpoint, &colorMode); - if (colorMode == ColorControl::EnhancedColorMode::kColorTemperature) + if (static_cast(colorMode) == EnhancedColorMode::kColorTemperatureMireds) { app::DataModel::Nullable currentLevel; Status status = LevelControl::Attributes::CurrentLevel::Get(endpoint, currentLevel); diff --git a/src/app/clusters/color-control-server/color-control-server.h b/src/app/clusters/color-control-server/color-control-server.h index 4238fed1dd8b2d..1ed9e33c403538 100644 --- a/src/app/clusters/color-control-server/color-control-server.h +++ b/src/app/clusters/color-control-server/color-control-server.h @@ -71,18 +71,10 @@ class ColorControlServer /********************************************************** * Enums *********************************************************/ - using HueStepMode = chip::app::Clusters::ColorControl::HueStepMode; - using HueMoveMode = chip::app::Clusters::ColorControl::HueMoveMode; - using HueDirection = chip::app::Clusters::ColorControl::HueDirection; - using Feature = chip::app::Clusters::ColorControl::Feature; - - enum EnhancedColorMode : uint8_t - { - kCurrentHueAndCurrentSaturation = 0, - kCurrentXAndCurrentY = 1, - kColorTemperature = 2, - kEnhancedCurrentHueAndCurrentSaturation = 3, - }; + using StepModeEnum = chip::app::Clusters::ColorControl::StepModeEnum; + using MoveModeEnum = chip::app::Clusters::ColorControl::MoveModeEnum; + using DirectionEnum = chip::app::Clusters::ColorControl::DirectionEnum; + using Feature = chip::app::Clusters::ColorControl::Feature; enum Conversion { @@ -150,20 +142,27 @@ class ColorControlServer bool HasFeature(chip::EndpointId endpoint, Feature feature); chip::Protocols::InteractionModel::Status stopAllColorTransitions(chip::EndpointId endpoint); bool stopMoveStepCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - uint8_t optionsMask, uint8_t optionsOverride); + chip::BitMask optionsMask, + chip::BitMask optionsOverride); #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_HSV bool moveHueCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - HueMoveMode moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride, bool isEnhanced); + MoveModeEnum moveMode, uint16_t rate, + chip::BitMask optionsMask, + chip::BitMask optionsOverride, bool isEnhanced); bool moveToHueCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, uint16_t hue, - HueDirection moveDirection, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride, - bool isEnhanced); + DirectionEnum moveDirection, uint16_t transitionTime, + chip::BitMask optionsMask, + chip::BitMask optionsOverride, bool isEnhanced); bool moveToHueAndSaturationCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - uint16_t hue, uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride, bool isEnhanced); + uint16_t hue, uint8_t saturation, uint16_t transitionTime, + chip::BitMask optionsMask, + chip::BitMask optionsOverride, + bool isEnhanced); bool stepHueCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - HueStepMode stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride, bool isEnhanced); + StepModeEnum stepMode, uint16_t stepSize, uint16_t transitionTime, + chip::BitMask optionsMask, + chip::BitMask optionsOverride, bool isEnhanced); bool moveSaturationCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::ColorControl::Commands::MoveSaturation::DecodableType & commandData); bool moveToSaturationCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, @@ -224,8 +223,9 @@ class ColorControlServer } } - bool shouldExecuteIfOff(chip::EndpointId endpoint, uint8_t optionMask, uint8_t optionOverride); - void handleModeSwitch(chip::EndpointId endpoint, uint8_t newColorMode); + bool shouldExecuteIfOff(chip::EndpointId endpoint, chip::BitMask optionMask, + chip::BitMask optionOverride); + void handleModeSwitch(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorModeEnum newColorMode); uint16_t computeTransitionTimeFromStateAndRate(Color16uTransitionState * p, uint16_t rate); EmberEventControl * getEventControl(chip::EndpointId endpoint); void computePwmFromHsv(chip::EndpointId endpoint); diff --git a/src/app/clusters/service-area-server/service-area-cluster-objects.h b/src/app/clusters/service-area-server/service-area-cluster-objects.h index 1b040c53cdc1bf..66f20720701587 100644 --- a/src/app/clusters/service-area-server/service-area-cluster-objects.h +++ b/src/app/clusters/service-area-server/service-area-cluster-objects.h @@ -110,9 +110,9 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs:: { areaDesc.locationInfo.SetNonNull(); // Copy the name - auto sizeToCopy = std::min(sizeof(mAreaNameBuffer), locationName.size()); - memcpy(mAreaNameBuffer, locationName.data(), sizeToCopy); - areaDesc.locationInfo.Value().locationName = CharSpan(mAreaNameBuffer, sizeToCopy); + auto areaNameSpan = MutableCharSpan(mAreaNameBuffer, kAreaNameMaxSize); + CopyCharSpanToMutableCharSpan(locationName, areaNameSpan); + areaDesc.locationInfo.Value().locationName = CharSpan(areaNameSpan.data(), areaNameSpan.size()); areaDesc.locationInfo.Value().floorNumber = floorNumber; areaDesc.locationInfo.Value().areaType = areaType; @@ -320,24 +320,10 @@ struct MapStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::M */ void Set(uint32_t aMapId, const CharSpan & aMapName) { - mapID = aMapId; - - if (aMapName.empty()) - { - name = CharSpan(mMapNameBuffer, 0); - } - else if (aMapName.size() > sizeof(mMapNameBuffer)) - { - // Save the truncated name that fits into available size. - memcpy(mMapNameBuffer, aMapName.data(), sizeof(mMapNameBuffer)); - name = CharSpan(mMapNameBuffer, sizeof(mMapNameBuffer)); - } - else - { - // Save full name. - memcpy(mMapNameBuffer, aMapName.data(), aMapName.size()); - name = CharSpan(mMapNameBuffer, aMapName.size()); - } + mapID = aMapId; + auto mapNameSpan = MutableCharSpan(mMapNameBuffer, kMapNameMaxSize); + CopyCharSpanToMutableCharSpan(aMapName, mapNameSpan); + name = CharSpan(mapNameSpan.data(), mapNameSpan.size()); } /** diff --git a/src/app/clusters/service-area-server/service-area-server.cpp b/src/app/clusters/service-area-server/service-area-server.cpp index a7e81278838ae6..baf56cd4fc84be 100644 --- a/src/app/clusters/service-area-server/service-area-server.cpp +++ b/src/app/clusters/service-area-server/service-area-server.cpp @@ -373,20 +373,11 @@ void Instance::HandleSkipAreaCmd(HandlerContext & ctx, const Commands::SkipArea: // If the Status field is set to InvalidAreaList, the StatusText field SHALL be an empty string. if (!IsSupportedArea(req.skippedArea)) { - ChipLogError(Zcl, "SkippedArea (%u) is not in the SupportedAreas attribute.", req.skippedArea); + ChipLogError(Zcl, "SkippedArea (%" PRIu32 ") is not in the SupportedAreas attribute.", req.skippedArea); exitResponse(SkipAreaStatus::kInvalidAreaList, ""_span); return; } - // If the CurrentArea attribute is null, the status should be set to InvalidInMode. - // If the Status field is not set to Success, or InvalidAreaList, the StatusText field SHALL include a vendor defined error - // description. - if (mCurrentArea.IsNull()) - { - exitResponse(SkipAreaStatus::kInvalidInMode, "Current Area attribute is null"_span); - return; - } - // have the device attempt to skip // If the Status field is not set to Success, or InvalidAreaList, the StatusText field SHALL include a vendor defined error // description. InvalidInMode | The received request cannot be handled due to the current mode of the device. (skipStatusText to @@ -453,7 +444,7 @@ bool Instance::IsValidSupportedArea(const AreaStructureWrapper & aArea) // If the LandmarkInfo field is null, the LocationInfo field SHALL NOT be null. if (aArea.areaDesc.locationInfo.IsNull() && aArea.areaDesc.landmarkInfo.IsNull()) { - ChipLogDetail(Zcl, "IsValidAsSupportedArea %u - must have locationInfo and/or LandmarkInfo", aArea.areaID); + ChipLogDetail(Zcl, "IsValidAsSupportedArea %" PRIu32 " - must have locationInfo and/or LandmarkInfo", aArea.areaID); return false; } @@ -464,8 +455,9 @@ bool Instance::IsValidSupportedArea(const AreaStructureWrapper & aArea) if (aArea.areaDesc.locationInfo.Value().locationName.empty() && aArea.areaDesc.locationInfo.Value().floorNumber.IsNull() && aArea.areaDesc.locationInfo.Value().areaType.IsNull() && aArea.areaDesc.landmarkInfo.IsNull()) { - ChipLogDetail(Zcl, "IsValidAsSupportedArea %u - AreaName is empty string, FloorNumber, AreaType, LandmarkInfo are null", - aArea.areaID); + ChipLogDetail( + Zcl, "IsValidAsSupportedArea %" PRIu32 " - AreaName is empty string, FloorNumber, AreaType, LandmarkInfo are null", + aArea.areaID); return false; } } @@ -475,14 +467,15 @@ bool Instance::IsValidSupportedArea(const AreaStructureWrapper & aArea) { if (aArea.mapID.IsNull()) { - ChipLogDetail(Zcl, "IsValidSupportedArea %u - map Id should not be null when there are supported maps", aArea.areaID); + ChipLogDetail(Zcl, "IsValidSupportedArea %" PRIu32 " - map Id should not be null when there are supported maps", + aArea.areaID); return false; } // If the SupportedMaps attribute is not null, mapID SHALL be the ID of an entry from the SupportedMaps attribute. if (!IsSupportedMap(aArea.mapID.Value())) { - ChipLogError(Zcl, "IsValidSupportedArea %u - map Id %u is not in supported map list", aArea.areaID, + ChipLogError(Zcl, "IsValidSupportedArea %" PRIu32 " - map Id %" PRIu32 " is not in supported map list", aArea.areaID, aArea.mapID.Value()); return false; } @@ -491,8 +484,8 @@ bool Instance::IsValidSupportedArea(const AreaStructureWrapper & aArea) { if (!aArea.mapID.IsNull()) { - ChipLogDetail(Zcl, "IsValidSupportedArea %u - map Id %u is not in empty supported map list", aArea.areaID, - aArea.mapID.Value()); + ChipLogDetail(Zcl, "IsValidSupportedArea %" PRIu32 " - map Id %" PRIu32 " is not in empty supported map list", + aArea.areaID, aArea.mapID.Value()); return false; } } @@ -578,14 +571,14 @@ bool Instance::AddSupportedArea(AreaStructureWrapper & aNewArea) // Check there is space for the entry. if (mDelegate->GetNumberOfSupportedAreas() >= kMaxNumSupportedAreas) { - ChipLogError(Zcl, "AddSupportedArea %u - too many entries", aNewArea.areaID); + ChipLogError(Zcl, "AddSupportedArea %" PRIu32 " - too many entries", aNewArea.areaID); return false; } // Verify cluster requirements concerning valid fields and field relationships. if (!IsValidSupportedArea(aNewArea)) { - ChipLogError(Zcl, "AddSupportedArea %u - not a valid location object", aNewArea.areaID); + ChipLogError(Zcl, "AddSupportedArea %" PRIu32 " - not a valid location object", aNewArea.areaID); return false; } @@ -595,7 +588,7 @@ bool Instance::AddSupportedArea(AreaStructureWrapper & aNewArea) // the AreaInfo field. if (!IsUniqueSupportedArea(aNewArea, false)) { - ChipLogError(Zcl, "AddSupportedArea %u - not a unique location object", aNewArea.areaID); + ChipLogError(Zcl, "AddSupportedArea %" PRIu32 " - not a unique location object", aNewArea.areaID); return false; } @@ -619,7 +612,7 @@ bool Instance::ModifySupportedArea(AreaStructureWrapper & aNewArea) AreaStructureWrapper supportedArea; if (!mDelegate->GetSupportedAreaById(aNewArea.areaID, listIndex, supportedArea)) { - ChipLogError(Zcl, "ModifySupportedArea %u - not a supported areaID", aNewArea.areaID); + ChipLogError(Zcl, "ModifySupportedArea %" PRIu32 " - not a supported areaID", aNewArea.areaID); return false; } @@ -639,7 +632,7 @@ bool Instance::ModifySupportedArea(AreaStructureWrapper & aNewArea) // verify cluster requirements concerning valid fields and field relationships if (!IsValidSupportedArea(aNewArea)) { - ChipLogError(Zcl, "ModifySupportedArea %u - not a valid location object", aNewArea.areaID); + ChipLogError(Zcl, "ModifySupportedArea %" PRIu32 " - not a valid location object", aNewArea.areaID); return false; } @@ -647,7 +640,7 @@ bool Instance::ModifySupportedArea(AreaStructureWrapper & aNewArea) // We ignore comparing the area ID as one of the locations will match this one. if (!IsUniqueSupportedArea(aNewArea, true)) { - ChipLogError(Zcl, "ModifySupportedArea %u - not a unique location object", aNewArea.areaID); + ChipLogError(Zcl, "ModifySupportedArea %" PRIu32 " - not a unique location object", aNewArea.areaID); return false; } @@ -701,14 +694,14 @@ bool Instance::AddSupportedMap(uint32_t aMapId, const CharSpan & aMapName) // check max# of list entries if (mDelegate->GetNumberOfSupportedMaps() >= kMaxNumSupportedMaps) { - ChipLogError(Zcl, "AddSupportedMap %u - maximum number of entries", aMapId); + ChipLogError(Zcl, "AddSupportedMap %" PRIu32 " - maximum number of entries", aMapId); return false; } // Map name SHALL include readable text that describes the map name (cannot be empty string). if (aMapName.empty()) { - ChipLogError(Zcl, "AddSupportedMap %u - Name must not be empty string", aMapId); + ChipLogError(Zcl, "AddSupportedMap %" PRIu32 " - Name must not be empty string", aMapId); return false; } @@ -721,7 +714,7 @@ bool Instance::AddSupportedMap(uint32_t aMapId, const CharSpan & aMapName) // the name cannot be the same as an existing map if (entry.IsNameEqual(aMapName)) { - ChipLogError(Zcl, "AddSupportedMap %u - A map already exists with same name '%.*s'", aMapId, + ChipLogError(Zcl, "AddSupportedMap %" PRIu32 " - A map already exists with same name '%.*s'", aMapId, static_cast(entry.GetName().size()), entry.GetName().data()); return false; } @@ -729,7 +722,7 @@ bool Instance::AddSupportedMap(uint32_t aMapId, const CharSpan & aMapName) // Each entry in this list SHALL have a unique value for the MapID field. if (aMapId == entry.mapID) { - ChipLogError(Zcl, "AddSupportedMap - non-unique Id %u", aMapId); + ChipLogError(Zcl, "AddSupportedMap - non-unique Id %" PRIu32 "", aMapId); return false; } } @@ -757,14 +750,14 @@ bool Instance::RenameSupportedMap(uint32_t aMapId, const CharSpan & newMapName) // get existing entry if (!mDelegate->GetSupportedMapById(aMapId, modifiedIndex, modifiedMap)) { - ChipLogError(Zcl, "RenameSupportedMap Id %u - map does not exist", aMapId); + ChipLogError(Zcl, "RenameSupportedMap Id %" PRIu32 " - map does not exist", aMapId); return false; } // Map name SHALL include readable text that describes the map's name. It cannot be empty string. if (newMapName.empty()) { - ChipLogError(Zcl, "RenameSupportedMap %u - Name must not be empty string", aMapId); + ChipLogError(Zcl, "RenameSupportedMap %" PRIu32 " - Name must not be empty string", aMapId); return false; } @@ -784,7 +777,7 @@ bool Instance::RenameSupportedMap(uint32_t aMapId, const CharSpan & newMapName) if (entry.IsNameEqual(newMapName)) { - ChipLogError(Zcl, "RenameSupportedMap %u - map already exists with same name '%.*s'", aMapId, + ChipLogError(Zcl, "RenameSupportedMap %" PRIu32 " - map already exists with same name '%.*s'", aMapId, static_cast(entry.GetName().size()), entry.GetName().data()); return false; } @@ -828,21 +821,21 @@ bool Instance::AddSelectedArea(uint32_t & aSelectedArea) // check max# of list entries if (mDelegate->GetNumberOfSelectedAreas() >= kMaxNumSelectedAreas) { - ChipLogError(Zcl, "AddSelectedArea %u - maximum number of entries", aSelectedArea); + ChipLogError(Zcl, "AddSelectedArea %" PRIu32 " - maximum number of entries", aSelectedArea); return false; } // each item in this list SHALL match the AreaID field of an entry on the SupportedAreas attribute's list if (!IsSupportedArea(aSelectedArea)) { - ChipLogError(Zcl, "AddSelectedArea %u - not a supported location", aSelectedArea); + ChipLogError(Zcl, "AddSelectedArea %" PRIu32 " - not a supported location", aSelectedArea); return false; } // each entry in this list SHALL have a unique value if (mDelegate->IsSelectedArea(aSelectedArea)) { - ChipLogError(Zcl, "AddSelectedArea %u - duplicated location", aSelectedArea); + ChipLogError(Zcl, "AddSelectedArea %" PRIu32 " - duplicated location", aSelectedArea); return false; } @@ -852,7 +845,7 @@ bool Instance::AddSelectedArea(uint32_t & aSelectedArea) if (!mDelegate->IsSetSelectedAreasAllowed(locationStatusText)) { - ChipLogError(Zcl, "AddSelectedArea %u - %.*s", aSelectedArea, static_cast(locationStatusText.size()), + ChipLogError(Zcl, "AddSelectedArea %" PRIu32 " - %.*s", aSelectedArea, static_cast(locationStatusText.size()), locationStatusText.data()); return false; } @@ -886,7 +879,7 @@ bool Instance::SetCurrentArea(const DataModel::Nullable & aCurrentArea // list. if ((!aCurrentArea.IsNull()) && (!IsSupportedArea(aCurrentArea.Value()))) { - ChipLogError(Zcl, "SetCurrentArea %u - location is not supported", aCurrentArea.Value()); + ChipLogError(Zcl, "SetCurrentArea %" PRIu32 " - location is not supported", aCurrentArea.Value()); return false; } @@ -955,14 +948,14 @@ bool Instance::AddPendingProgressElement(uint32_t aAreaId) // For each entry in this list, the AreaID field SHALL match an entry on the SupportedAreas attribute's list. if (!IsSupportedArea(aAreaId)) { - ChipLogError(Zcl, "AddPendingProgressElement - not a supported location %u", aAreaId); + ChipLogError(Zcl, "AddPendingProgressElement - not a supported location %" PRIu32 "", aAreaId); return false; } // Each entry in this list SHALL have a unique value for the AreaID field. if (mDelegate->IsProgressElement(aAreaId)) { - ChipLogError(Zcl, "AddPendingProgressElement - progress element already exists for location %u", aAreaId); + ChipLogError(Zcl, "AddPendingProgressElement - progress element already exists for location %" PRIu32 "", aAreaId); return false; } @@ -984,7 +977,7 @@ bool Instance::SetProgressStatus(uint32_t aAreaId, OperationalStatusEnum opStatu if (!mDelegate->GetProgressElementById(aAreaId, listIndex, progressElement)) { - ChipLogError(Zcl, "SetProgressStatus - progress element does not exist for location %u", aAreaId); + ChipLogError(Zcl, "SetProgressStatus - progress element does not exist for location %" PRIu32 "", aAreaId); return false; } @@ -1020,7 +1013,7 @@ bool Instance::SetProgressTotalOperationalTime(uint32_t aAreaId, const DataModel if (!mDelegate->GetProgressElementById(aAreaId, listIndex, progressElement)) { - ChipLogError(Zcl, "SetProgressTotalOperationalTime - progress element does not exist for location %u", aAreaId); + ChipLogError(Zcl, "SetProgressTotalOperationalTime - progress element does not exist for location %" PRIu32 "", aAreaId); return false; } @@ -1036,7 +1029,8 @@ bool Instance::SetProgressTotalOperationalTime(uint32_t aAreaId, const DataModel !aTotalOperationalTime.IsNull()) { ChipLogError(Zcl, - "SetProgressTotalOperationalTime - location %u opStatus value %u - can be non-null only if opStatus is " + "SetProgressTotalOperationalTime - location %" PRIu32 + " opStatus value %u - can be non-null only if opStatus is " "Completed or Skipped", aAreaId, to_underlying(progressElement.status)); return false; @@ -1062,7 +1056,7 @@ bool Instance::SetProgressEstimatedTime(uint32_t aAreaId, const DataModel::Nulla if (!mDelegate->GetProgressElementById(aAreaId, listIndex, progressElement)) { - ChipLogError(Zcl, "SetProgressEstimatedTime - progress element does not exist for location %u", aAreaId); + ChipLogError(Zcl, "SetProgressEstimatedTime - progress element does not exist for location %" PRIu32 "", aAreaId); return false; } diff --git a/src/app/clusters/thermostat-server/thermostat-delegate.h b/src/app/clusters/thermostat-server/thermostat-delegate.h index c8c21d898af167..0f89f69468099b 100644 --- a/src/app/clusters/thermostat-server/thermostat-delegate.h +++ b/src/app/clusters/thermostat-server/thermostat-delegate.h @@ -78,11 +78,10 @@ class Delegate /** * @brief Get the ActivePresetHandle attribute value. * - * @param[out] activePresetHandle The MutableByteSpan to copy the active preset handle into. On success, - * the callee must update the length to the length of the copied data. If the value of - * the attribute is null, the callee must set the MutableByteSpan to empty. + * @param[out] activePresetHandle The nullable MutableByteSpan to copy the active preset handle into. On success, + * the size of the activePresetHandle is updated to the length of the copied data. */ - virtual CHIP_ERROR GetActivePresetHandle(MutableByteSpan & activePresetHandle) = 0; + virtual CHIP_ERROR GetActivePresetHandle(DataModel::Nullable & activePresetHandle) = 0; /** * @brief Set the ActivePresetHandle attribute value. diff --git a/src/app/clusters/thermostat-server/thermostat-server.cpp b/src/app/clusters/thermostat-server/thermostat-server.cpp index 91c045c5ff540e..8fe70211eeda1a 100644 --- a/src/app/clusters/thermostat-server/thermostat-server.cpp +++ b/src/app/clusters/thermostat-server/thermostat-server.cpp @@ -761,19 +761,13 @@ CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, A VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Delegate is null")); uint8_t buffer[kPresetHandleSize]; - MutableByteSpan activePresetHandle(buffer); + MutableByteSpan activePresetHandleSpan(buffer); + auto activePresetHandle = DataModel::MakeNullable(activePresetHandleSpan); CHIP_ERROR err = delegate->GetActivePresetHandle(activePresetHandle); ReturnErrorOnFailure(err); - if (activePresetHandle.empty()) - { - ReturnErrorOnFailure(aEncoder.EncodeNull()); - } - else - { - ReturnErrorOnFailure(aEncoder.Encode(activePresetHandle)); - } + ReturnErrorOnFailure(aEncoder.Encode(activePresetHandle)); } break; case ScheduleTypes::Id: { @@ -1299,16 +1293,16 @@ bool emberAfThermostatClusterSetActivePresetRequestCallback( return true; } - ByteSpan newPresetHandle = commandData.presetHandle; + DataModel::Nullable newPresetHandle = commandData.presetHandle; // If the preset handle passed in the command is not present in the Presets attribute, return INVALID_COMMAND. - if (!IsPresetHandlePresentInPresets(delegate, newPresetHandle)) + if (!newPresetHandle.IsNull() && !IsPresetHandlePresentInPresets(delegate, newPresetHandle.Value())) { commandObj->AddStatus(commandPath, imcode::InvalidCommand); return true; } - CHIP_ERROR err = delegate->SetActivePresetHandle(DataModel::MakeNullable(newPresetHandle)); + CHIP_ERROR err = delegate->SetActivePresetHandle(newPresetHandle); if (err != CHIP_NO_ERROR) { @@ -1470,7 +1464,8 @@ imcode commitPresets(Delegate * delegate, EndpointId endpoint) // attribute. If a preset is not found with the same presetHandle, return INVALID_IN_STATE. If there is no ActivePresetHandle // attribute set, continue with other checks. uint8_t buffer[kPresetHandleSize]; - MutableByteSpan activePresetHandle(buffer); + MutableByteSpan activePresetHandleSpan(buffer); + auto activePresetHandle = DataModel::MakeNullable(activePresetHandleSpan); err = delegate->GetActivePresetHandle(activePresetHandle); @@ -1479,9 +1474,9 @@ imcode commitPresets(Delegate * delegate, EndpointId endpoint) return imcode::InvalidInState; } - if (!activePresetHandle.empty()) + if (!activePresetHandle.IsNull()) { - uint8_t count = CountPresetsInPendingListWithPresetHandle(delegate, activePresetHandle); + uint8_t count = CountPresetsInPendingListWithPresetHandle(delegate, activePresetHandle.Value()); if (count == 0) { return imcode::InvalidInState; diff --git a/src/app/common/CompatEnumNames.h b/src/app/common/CompatEnumNames.h index ceb91c1981d203..a3154cbb682975 100644 --- a/src/app/common/CompatEnumNames.h +++ b/src/app/common/CompatEnumNames.h @@ -21,6 +21,8 @@ */ #pragma once +#include + namespace chip { namespace app { namespace Clusters { @@ -80,6 +82,50 @@ using StepMode = StepModeEnum; using LevelControlOptions = OptionsBitmap; } // namespace LevelControl +namespace ColorControl { +// https://github.com/project-chip/connectedhomeip/pull/33612 renamed this +enum class ColorMode : uint8_t +{ + kCurrentHueAndCurrentSaturation = to_underlying(ColorModeEnum::kCurrentHueAndCurrentSaturation), + kCurrentXAndCurrentY = to_underlying(ColorModeEnum::kCurrentXAndCurrentY), + kColorTemperature = to_underlying(ColorModeEnum::kColorTemperatureMireds), + kUnknownEnumValue = to_underlying(ColorModeEnum::kUnknownEnumValue) +}; + +enum class HueDirection : uint8_t +{ + ShortestDistance = to_underlying(DirectionEnum::kShortest), + LongestDistance = to_underlying(DirectionEnum::kLongest), + Up = to_underlying(DirectionEnum::kUp), + Down = to_underlying(DirectionEnum::kDown), + kUnknownEnumValue = to_underlying(DirectionEnum::kUnknownEnumValue) +}; + +enum class ColorCapabilities : uint16_t +{ + ColorLoopSupported = to_underlying(ColorCapabilitiesBitmap::kColorLoop), + ColorTemperatureSupported = to_underlying(ColorCapabilitiesBitmap::kColorTemperature), + EnhancedHueSupported = to_underlying(ColorCapabilitiesBitmap::kEnhancedHue), + HueSaturationSupported = to_underlying(ColorCapabilitiesBitmap::kHueSaturation), + XYAttributesSupported = to_underlying(ColorCapabilitiesBitmap::kXy) +}; + +enum class ColorLoopDirection : uint8_t +{ + DecrementHue = to_underlying(ColorLoopDirectionEnum::kDecrement), + IncrementHue = to_underlying(ColorLoopDirectionEnum::kIncrement), + kUnknownEnumValue = to_underlying(ColorLoopDirectionEnum::kUnknownEnumValue) +}; + +using EnhancedColorMode = EnhancedColorModeEnum; +using ColorLoopUpdateFlags = UpdateFlagsBitmap; +using ColorLoopAction = ColorLoopActionEnum; +using HueMoveMode = MoveModeEnum; +using HueStepMode = StepModeEnum; +using SaturationMoveMode = MoveModeEnum; +using SaturationStepMode = StepModeEnum; +} // namespace ColorControl + namespace RefrigeratorAlarm { // https://github.com/project-chip/connectedhomeip/pull/31517 renamed this using AlarmMap = AlarmBitmap; diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index 1bce08d55e0571..104a57a2fc019a 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -194,6 +194,7 @@ chip_test_suite("tests") { "TestBasicCommandPathRegistry.cpp", "TestBindingTable.cpp", "TestBuilderParser.cpp", + "TestCommandHandlerInterfaceRegistry.cpp", "TestCommandInteraction.cpp", "TestCommandPathParams.cpp", "TestConcreteAttributePath.cpp", diff --git a/src/app/tests/TestCommandHandlerInterfaceRegistry.cpp b/src/app/tests/TestCommandHandlerInterfaceRegistry.cpp new file mode 100644 index 00000000000000..aed017362c83f5 --- /dev/null +++ b/src/app/tests/TestCommandHandlerInterfaceRegistry.cpp @@ -0,0 +1,103 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#include + +namespace chip { +namespace app { + +namespace { + +class TestCommandHandlerInterface : public CommandHandlerInterface +{ +public: + TestCommandHandlerInterface(Optional endpointId, ClusterId clusterId) : + CommandHandlerInterface(endpointId, clusterId) + {} + + // Just need this to compile + void InvokeCommand(HandlerContext & handlerContext) override {} +}; + +} // anonymous namespace + +TEST(TestCommandHandlerInterfaceRegistry, TestRegisterUnregister) +{ + TestCommandHandlerInterface a(Optional(1), 1); + TestCommandHandlerInterface b(Optional(1), 2); + TestCommandHandlerInterface c(Optional(2), 1); + TestCommandHandlerInterface d(NullOptional, 3); + + CommandHandlerInterfaceRegistry registry; + EXPECT_EQ(registry.RegisterCommandHandler(&a), CHIP_NO_ERROR); + EXPECT_EQ(registry.RegisterCommandHandler(&b), CHIP_NO_ERROR); + EXPECT_EQ(registry.RegisterCommandHandler(&c), CHIP_NO_ERROR); + EXPECT_EQ(registry.RegisterCommandHandler(&d), CHIP_NO_ERROR); + + EXPECT_EQ(registry.GetCommandHandler(1, 1), &a); + EXPECT_EQ(registry.GetCommandHandler(1, 2), &b); + EXPECT_EQ(registry.GetCommandHandler(2, 1), &c); + EXPECT_EQ(registry.GetCommandHandler(1, 3), &d); + EXPECT_EQ(registry.GetCommandHandler(5, 3), &d); + + EXPECT_EQ(registry.UnregisterCommandHandler(&b), CHIP_NO_ERROR); + + EXPECT_EQ(registry.GetCommandHandler(1, 1), &a); + EXPECT_EQ(registry.GetCommandHandler(1, 2), nullptr); + EXPECT_EQ(registry.GetCommandHandler(2, 1), &c); + EXPECT_EQ(registry.GetCommandHandler(1, 3), &d); + EXPECT_EQ(registry.GetCommandHandler(5, 3), &d); + + EXPECT_EQ(registry.UnregisterCommandHandler(&b), CHIP_ERROR_KEY_NOT_FOUND); +} + +TEST(TestCommandHandlerInterfaceRegistry, TestUnregisterAll) +{ + TestCommandHandlerInterface a(Optional(1), 1); + TestCommandHandlerInterface b(Optional(1), 2); + TestCommandHandlerInterface c(Optional(2), 1); + TestCommandHandlerInterface d(NullOptional, 3); + + CommandHandlerInterfaceRegistry registry; + EXPECT_EQ(registry.RegisterCommandHandler(&a), CHIP_NO_ERROR); + EXPECT_EQ(registry.RegisterCommandHandler(&b), CHIP_NO_ERROR); + EXPECT_EQ(registry.RegisterCommandHandler(&c), CHIP_NO_ERROR); + EXPECT_EQ(registry.RegisterCommandHandler(&d), CHIP_NO_ERROR); + + EXPECT_EQ(registry.GetCommandHandler(1, 1), &a); + EXPECT_EQ(registry.GetCommandHandler(1, 2), &b); + EXPECT_EQ(registry.GetCommandHandler(2, 1), &c); + EXPECT_EQ(registry.GetCommandHandler(1, 3), &d); + EXPECT_EQ(registry.GetCommandHandler(5, 3), &d); + + registry.UnregisterAllCommandHandlersForEndpoint(1); + + EXPECT_EQ(registry.GetCommandHandler(1, 1), nullptr); + EXPECT_EQ(registry.GetCommandHandler(1, 2), nullptr); + EXPECT_EQ(registry.GetCommandHandler(2, 1), &c); + EXPECT_EQ(registry.GetCommandHandler(1, 3), &d); + EXPECT_EQ(registry.GetCommandHandler(5, 3), &d); +} + +} // namespace app +} // namespace chip diff --git a/src/app/tests/suites/certification/Test_TC_ACT_3_2.yaml b/src/app/tests/suites/certification/Test_TC_ACT_3_2.yaml index 914718896d97ca..cc409a67c6611d 100644 --- a/src/app/tests/suites/certification/Test_TC_ACT_3_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_ACT_3_2.yaml @@ -33,7 +33,7 @@ tests: "Step 0: Preparation: TH as server exposes an Actions server cluster on EP 1, with one action (supporting all possible commands) and corresponding ActionLists and EndpointLists attributes: ActionList: - contains one list element (ActionListStruct): ActionIO = 0x1001 Name + contains one list element (ActionListStruct): ActionIO = 0xA001 Name = 'some test' Type = other EndpointListID = 0xE001 SupportedCommands = 0x0fff // suppports all commands State = Inactive EndpointLists: contains one list element @@ -92,13 +92,13 @@ tests: 2. Use the above obtained ActionID to verify the following commands - ./chip-tool actions instant-action 4097 1 1 + ./chip-tool actions instant-action 40961 1 1 disabled: true - label: "Step 1: DUT issues an InstantAction command to TH" PICS: ACT.C.C00.Tx verification: | - ./chip-tool actions instant-action 4097 1 1 + ./chip-tool actions instant-action 40961 1 1 Via the TH (bridge-app), verify the InstantAction response that contains ActionID . diff --git a/src/app/tests/suites/TestFabricSyncBridgedNode.yaml b/src/app/tests/suites/certification/Test_TC_BR_5.yaml similarity index 96% rename from src/app/tests/suites/TestFabricSyncBridgedNode.yaml rename to src/app/tests/suites/certification/Test_TC_BR_5.yaml index 6624e710127442..958f98d076884f 100644 --- a/src/app/tests/suites/TestFabricSyncBridgedNode.yaml +++ b/src/app/tests/suites/certification/Test_TC_BR_5.yaml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Test Fabric Synchronization condition on Bridged Node Device Type +name: 3.1.5. [TC-BR-5] Conditions for Fabric Synchronization (DUT server) PICS: - MCORE.FS diff --git a/src/app/tests/suites/certification/Test_TC_CC_7_3.yaml b/src/app/tests/suites/certification/Test_TC_CC_7_3.yaml index bfdfd26ed3ca1a..4aae05d10fd1cd 100644 --- a/src/app/tests/suites/certification/Test_TC_CC_7_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_CC_7_3.yaml @@ -162,7 +162,7 @@ tests: maxValue: 13800 - label: - "Step 5a: TH sends EnhancedMoveToHue command to DUT with + "Step 3a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)." PICS: CC.S.F01 && CC.S.C40.Rsp @@ -190,7 +190,7 @@ tests: value: 100 - label: - "Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 + "Step 3b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s)" PICS: CC.S.F01 && CC.S.C42.Rsp command: "EnhancedStepHue" @@ -216,7 +216,7 @@ tests: - name: "ms" value: 10000 - - label: "Step 5c: TH reads EnhancedCurrentHue attribute from DUT" + - label: "Step 3c: TH reads EnhancedCurrentHue attribute from DUT" command: "readAttribute" PICS: CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp attribute: "EnhancedCurrentHue" @@ -234,7 +234,7 @@ tests: - name: "ms" value: 10000 - - label: "Step 2d: TH reads EnhancedCurrentHue attribute from DUT" + - label: "Step 3d: TH reads EnhancedCurrentHue attribute from DUT" command: "readAttribute" PICS: CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp attribute: "EnhancedCurrentHue" @@ -252,7 +252,7 @@ tests: - name: "ms" value: 10000 - - label: "Step 2e: TH reads EnhancedCurrentHue attribute from DUT" + - label: "Step 3e: TH reads EnhancedCurrentHue attribute from DUT" command: "readAttribute" PICS: CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp attribute: "EnhancedCurrentHue" @@ -270,7 +270,7 @@ tests: - name: "ms" value: 5000 - - label: "Step 2f: TH reads EnhancedCurrentHue attribute from DUT" + - label: "Step 3f: TH reads EnhancedCurrentHue attribute from DUT" command: "readAttribute" PICS: CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp attribute: "EnhancedCurrentHue" @@ -279,7 +279,7 @@ tests: minValue: 5100 maxValue: 6900 - - label: "Step 6a: TH reads ColorMode attribute from DUT" + - label: "Step 4a: TH reads ColorMode attribute from DUT" PICS: CC.S.F01 && CC.S.A0008 command: "readAttribute" attribute: "ColorMode" @@ -289,7 +289,7 @@ tests: minValue: 0 maxValue: 2 - - label: "Step 6b: TH reads EnhancedColorMode attribute from DUT" + - label: "Step 4b: TH reads EnhancedColorMode attribute from DUT" PICS: CC.S.F01 && CC.S.A4001 command: "readAttribute" attribute: "EnhancedColorMode" @@ -300,7 +300,7 @@ tests: maxValue: 3 - label: - "Step 7a: TH sends EnhancedStepHue command to DUT with StepMode=0x01 + "Step 5a: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=0" PICS: CC.S.F01 && CC.S.C42.Rsp command: "EnhancedStepHue" @@ -320,7 +320,7 @@ tests: error: INVALID_COMMAND - label: - "Step 7b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 + "Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=0" PICS: CC.S.F01 && CC.S.C42.Rsp command: "EnhancedStepHue" diff --git a/src/app/tests/suites/certification/Test_TC_SC_4_10.yaml b/src/app/tests/suites/certification/Test_TC_SC_4_10.yaml deleted file mode 100644 index 987bc6279093a8..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_SC_4_10.yaml +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2021 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. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: - 15.4.10. [TC-SC-4.10] Operational Discovery - SIT ICD Node - [{DUT_Commissionee}] - -PICS: - - MCORE.ROLE.COMMISSIONEE - - MCORE.SC.SED - -config: - nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 - -tests: - - label: "Precondition" - verification: | - 1. Nodes are joined in the same Fabric - 2. DUT is a sleepy device (MCORE.SC.SED) - disabled: true - - - label: "Step 1: DUT is instructed to advertise its service" - verification: | - 1. Provision the DUT by TH (Chip-tool) - disabled: true - - - label: "Step 2: TH scans for DNS-SD advertising" - verification: | - avahi-browse -rt _matter._tcp - On the TH(Chip-tool) Log: Verify the DUT is advertising for: - - SII key is higher than the SESSION_IDLE_INTERVAL default value (> 500 milliseconds) - - SII key and SAI key is less than 3600000 (1hour in milliseconds) - - + eth0 IPv6 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - + eth0 IPv4 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - = eth0 IPv4 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - hostname = [D21165B5F440B033.local] - address = [fd11:22::4b31:9932:cffe:b41a] - port = [5540] - txt = ["T=0" "SAI=300" "SII=5000" "SAT=4000"] - = eth0 IPv6 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - hostname = [D21165B5F440B033.local] - address = [fd11:22::4b31:9932:cffe:b41a] - port = [5540] - txt = ["T=0" "SAI=300" "SII=5000"] - disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_SC_4_5.yaml b/src/app/tests/suites/certification/Test_TC_SC_4_5.yaml deleted file mode 100644 index a3ba4b4f41ab1d..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_SC_4_5.yaml +++ /dev/null @@ -1,92 +0,0 @@ -# Copyright (c) 2021 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. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: 15.4.5. [TC-SC-4.5] Discovery [DUT as Commissionee][Thread] - -PICS: - - MCORE.ROLE.COMMISSIONEE - -config: - nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 - -tests: - - label: - "Step 1: TH is instructed to start advertising two or more services - using DNS-SD" - verification: | - 1. On the raspi controller, publish matter service, using below command - - $avahi-publish-service 87E1B004E235A130-8FC7772401CD0696 _matter._tcp 22222 SII=3000 SAI=4000 T=0 - disabled: true - - - label: - "Step 2: By any means, DUT is instructed to perform an unicast UDP - query to the DNS-SD Discovery Proxy on TH for services" - PICS: - MCORE.SC.SII_OP_DISCOVERY_KEY && MCORE.SC.SAI_OP_DISCOVERY_KEY && - MCORE.SC.T_KEY - verification: | - avahi-browse -rt _matter._tcp - - Verify advertisement on the TH Log: - - + eth0 IPv6 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - + eth0 IPv4 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - = eth0 IPv4 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - hostname = [D21165B5F440B033.local] - address = [fd11:22::4b31:9932:cffe:b41a] - port = [5540] - txt = ["T=0" "SAI=300" "SII=5000"] - = eth0 IPv6 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - hostname = [D21165B5F440B033.local] - address = [fd11:22::4b31:9932:cffe:b41a] - port = [5540] - txt = ["T=0" "SAI=300" "SII=5000"] - disabled: true - - - label: - "Step 3: TH performs a change in one of the services configured at - step 1" - verification: | - 1. On the raspi controller, publish matter service chanding the T value 1, using below command - - $avahi-publish-service 87E1B004E235A130-8FC7772401CD0696 _matter._tcp 22222 SII=3000 SAI=4000 T=1 - disabled: true - - - label: "Step 4: DUT must receive a notification with new data" - PICS: - MCORE.SC.SII_OP_DISCOVERY_KEY && MCORE.SC.SAI_OP_DISCOVERY_KEY && - MCORE.SC.T_KEY - verification: | - avahi-browse -rt _matter._tcp - - - Verify advertisement on the TH Log: - - + eth0 IPv6 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - + eth0 IPv4 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - = eth0 IPv4 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - hostname = [D21165B5F440B033.local] - address = [fd11:22::4b31:9932:cffe:b41a] - port = [5540] - txt = ["T=1" "SAI=300" "SII=5000"] - = eth0 IPv6 3A235FF3FA2DAC10-0000000000000055 _matter._tcp local - hostname = [D21165B5F440B033.local] - address = [fd11:22::4b31:9932:cffe:b41a] - port = [5540] - txt = ["T=1" "SAI=300" "SII=5000"] - disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml index bdb3d2b8ad90db..7e5121680ceffd 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml @@ -50,36 +50,6 @@ tests: - name: "SceneTableSize" saveAs: maxScenes - - label: "Arithmetic operation to get the maxScenes - 1" - cluster: "Unit Testing" - command: "TestAddArguments" - arguments: - values: - - name: "arg1" - value: maxScenes - 1 - - name: "arg2" - value: 0 - response: - values: - - name: "returnValue" - saveAs: maxScenesMinusOne - value: maxScenes - 1 - - - label: "Arithmetic operation to get the fabric Capacity" - cluster: "Unit Testing" - command: "TestAddArguments" - arguments: - values: - - name: "arg1" - value: maxScenesMinusOne / 2 - - name: "arg2" - value: 0 - response: - values: - - name: "returnValue" - saveAs: fabricCapacity - value: maxScenesMinusOne / 2 - - label: "Step 0a :TH reads attribute {ServerList} from the Descriptor cluster of the endpoint that implements the Scenes Management server on the @@ -202,7 +172,8 @@ tests: - name: "Status" value: 0x00 - name: "Capacity" - value: fabricCapacity + value: (maxScenes - 1) / 2 + saveAs: fabricCapacity - name: "GroupID" value: G1 diff --git a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml index 5a76916edb39b7..817ab532bad66c 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml @@ -50,36 +50,6 @@ tests: - name: "SceneTableSize" saveAs: maxScenes - - label: "Arithmetic operation to get the maxScenes - 1" - cluster: "Unit Testing" - command: "TestAddArguments" - arguments: - values: - - name: "arg1" - value: maxScenes - 1 - - name: "arg2" - value: 0 - response: - values: - - name: "returnValue" - saveAs: maxScenesMinusOne - value: maxScenes - 1 - - - label: "Arithmetic operation to get the fabric Capacity" - cluster: "Unit Testing" - command: "TestAddArguments" - arguments: - values: - - name: "arg1" - value: maxScenesMinusOne / 2 - - name: "arg2" - value: 0 - response: - values: - - name: "returnValue" - saveAs: fabricCapacity - value: maxScenesMinusOne / 2 - - label: "Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. @@ -259,7 +229,8 @@ tests: - name: "Status" value: 0x00 - name: "Capacity" - value: fabricCapacity + value: (maxScenes - 1) / 2 + saveAs: fabricCapacity - name: "GroupID" value: G1 - name: "SceneList" diff --git a/src/app/zap-templates/zcl/data-model/chip/color-control-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/color-control-cluster.xml index c97d4a59baa00b..f72140e712a703 100644 --- a/src/app/zap-templates/zcl/data-model/chip/color-control-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/color-control-cluster.xml @@ -17,57 +17,44 @@ limitations under the License. - + - - + + - + - + - - - - - - - - - - - - - - + - + - + - - - - - + + + + + - + @@ -75,17 +62,39 @@ limitations under the License. - + - + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -128,15 +137,15 @@ limitations under the License. CurrentY - DriftCompensation + DriftCompensation CompensationText ColorTemperatureMireds - ColorMode + ColorMode - Options + Options NumberOfPrimaries @@ -254,31 +263,31 @@ limitations under the License. Move to specified hue. - + - - + + Move hue up or down at specified rate. - + - - + + Step hue up or down by specified size at specified rate. - + - - + + @@ -287,29 +296,29 @@ limitations under the License. - - + + Move saturation up or down at specified rate. - + - - + + Step saturation up or down by specified size at specified rate. - + - - + + @@ -319,8 +328,8 @@ limitations under the License. - - + + @@ -330,8 +339,8 @@ limitations under the License. - - + + @@ -340,8 +349,8 @@ limitations under the License. - - + + @@ -351,8 +360,8 @@ limitations under the License. - - + + @@ -361,20 +370,20 @@ limitations under the License. - - + + EnhancedCurrentHue - EnhancedColorMode - ColorLoopActive - ColorLoopDirection + EnhancedColorMode + ColorLoopActive + ColorLoopDirection ColorLoopTime ColorLoopStartEnhancedHue ColorLoopStoredEnhancedHue - ColorCapabilities + ColorCapabilities ColorTempPhysicalMinMireds ColorTempPhysicalMaxMireds @@ -383,31 +392,31 @@ limitations under the License. Command description for EnhancedMoveToHue - + - - + + Command description for EnhancedMoveHue - + - - + + Command description for EnhancedStepHue - + - - + + @@ -417,54 +426,54 @@ limitations under the License. - - + + Command description for ColorLoopSet - - - + + + - - + + Command description for StopMoveStep - - + + Command description for MoveColorTemperature - + - - + + Command description for StepColorTemperature - + - - + + 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 14f4b9edf39958..ea18e985628071 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 @@ -2209,6 +2209,12 @@ limitations under the License. 0x0070 Simple Endpoint + + tree + + 0x0071 + + diff --git a/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml index 546692b1a42030..6f75aa45e985f6 100644 --- a/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml @@ -481,7 +481,7 @@ limitations under the License. ID - + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 02408e1ecf74b0..52f43c048aed14 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -6994,7 +6994,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -7145,65 +7145,62 @@ cluster ThermostatUserInterfaceConfiguration = 516 { cluster ColorControl = 768 { revision 7; - enum ColorLoopAction : enum8 { + enum ColorLoopActionEnum : enum8 { kDeactivate = 0; kActivateFromColorLoopStartEnhancedHue = 1; kActivateFromEnhancedCurrentHue = 2; } - enum ColorLoopDirection : enum8 { - kDecrementHue = 0; - kIncrementHue = 1; + enum ColorLoopDirectionEnum : enum8 { + kDecrement = 0; + kIncrement = 1; } - enum ColorMode : enum8 { + enum ColorModeEnum : enum8 { kCurrentHueAndCurrentSaturation = 0; kCurrentXAndCurrentY = 1; - kColorTemperature = 2; + kColorTemperatureMireds = 2; } - enum HueDirection : enum8 { - kShortestDistance = 0; - kLongestDistance = 1; + enum DirectionEnum : enum8 { + kShortest = 0; + kLongest = 1; kUp = 2; kDown = 3; } - enum HueMoveMode : enum8 { - kStop = 0; - kUp = 1; - kDown = 3; + enum DriftCompensationEnum : enum8 { + kNone = 0; + kOtherOrUnknown = 1; + kTemperatureMonitoring = 2; + kOpticalLuminanceMonitoringAndFeedback = 3; + kOpticalColorMonitoringAndFeedback = 4; } - enum HueStepMode : enum8 { - kUp = 1; - kDown = 3; + enum EnhancedColorModeEnum : enum8 { + kCurrentHueAndCurrentSaturation = 0; + kCurrentXAndCurrentY = 1; + kColorTemperatureMireds = 2; + kEnhancedCurrentHueAndCurrentSaturation = 3; } - enum SaturationMoveMode : enum8 { + enum MoveModeEnum : enum8 { kStop = 0; kUp = 1; kDown = 3; } - enum SaturationStepMode : enum8 { + enum StepModeEnum : enum8 { kUp = 1; kDown = 3; } - bitmap ColorCapabilities : bitmap16 { - kHueSaturationSupported = 0x1; - kEnhancedHueSupported = 0x2; - kColorLoopSupported = 0x4; - kXYAttributesSupported = 0x8; - kColorTemperatureSupported = 0x10; - } - - bitmap ColorLoopUpdateFlags : bitmap8 { - kUpdateAction = 0x1; - kUpdateDirection = 0x2; - kUpdateTime = 0x4; - kUpdateStartHue = 0x8; + bitmap ColorCapabilitiesBitmap : bitmap16 { + kHueSaturation = 0x1; + kEnhancedHue = 0x2; + kColorLoop = 0x4; + kXY = 0x8; + kColorTemperature = 0x10; } bitmap Feature : bitmap32 { @@ -7214,16 +7211,27 @@ cluster ColorControl = 768 { kColorTemperature = 0x10; } + bitmap OptionsBitmap : bitmap8 { + kExecuteIfOff = 0x1; + } + + bitmap UpdateFlagsBitmap : bitmap8 { + kUpdateAction = 0x1; + kUpdateDirection = 0x2; + kUpdateTime = 0x4; + kUpdateStartHue = 0x8; + } + readonly attribute optional int8u currentHue = 0; readonly attribute optional int8u currentSaturation = 1; readonly attribute optional int16u remainingTime = 2; readonly attribute optional int16u currentX = 3; readonly attribute optional int16u currentY = 4; - readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional DriftCompensationEnum driftCompensation = 5; readonly attribute optional char_string<254> compensationText = 6; readonly attribute optional int16u colorTemperatureMireds = 7; - readonly attribute enum8 colorMode = 8; - attribute bitmap8 options = 15; + readonly attribute ColorModeEnum colorMode = 8; + attribute OptionsBitmap options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; readonly attribute optional int16u primary1X = 17; readonly attribute optional int16u primary1Y = 18; @@ -7255,13 +7263,13 @@ cluster ColorControl = 768 { attribute access(write: manage) optional int16u colorPointBY = 59; attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; readonly attribute optional int16u enhancedCurrentHue = 16384; - readonly attribute enum8 enhancedColorMode = 16385; + readonly attribute EnhancedColorModeEnum enhancedColorMode = 16385; readonly attribute optional int8u colorLoopActive = 16386; readonly attribute optional int8u colorLoopDirection = 16387; readonly attribute optional int16u colorLoopTime = 16388; readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; - readonly attribute bitmap16 colorCapabilities = 16394; + readonly attribute ColorCapabilitiesBitmap colorCapabilities = 16394; readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; @@ -7275,150 +7283,150 @@ cluster ColorControl = 768 { request struct MoveToHueRequest { int8u hue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToSaturationRequest { int8u saturation = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct MoveSaturationRequest { - SaturationMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int8u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepSaturationRequest { - SaturationStepMode stepMode = 0; + StepModeEnum stepMode = 0; int8u stepSize = 1; int8u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToHueAndSaturationRequest { int8u hue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorRequest { int16u colorX = 0; int16u colorY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveColorRequest { int16s rateX = 0; int16s rateY = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct StepColorRequest { int16s stepX = 0; int16s stepY = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct MoveToColorTemperatureRequest { int16u colorTemperatureMireds = 0; int16u transitionTime = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedMoveToHueRequest { int16u enhancedHue = 0; - HueDirection direction = 1; + DirectionEnum direction = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveHueRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; - bitmap8 optionsMask = 2; - bitmap8 optionsOverride = 3; + OptionsBitmap optionsMask = 2; + OptionsBitmap optionsOverride = 3; } request struct EnhancedStepHueRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct EnhancedMoveToHueAndSaturationRequest { int16u enhancedHue = 0; int8u saturation = 1; int16u transitionTime = 2; - bitmap8 optionsMask = 3; - bitmap8 optionsOverride = 4; + OptionsBitmap optionsMask = 3; + OptionsBitmap optionsOverride = 4; } request struct ColorLoopSetRequest { - ColorLoopUpdateFlags updateFlags = 0; - ColorLoopAction action = 1; - ColorLoopDirection direction = 2; + UpdateFlagsBitmap updateFlags = 0; + ColorLoopActionEnum action = 1; + ColorLoopDirectionEnum direction = 2; int16u time = 3; int16u startHue = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } request struct StopMoveStepRequest { - bitmap8 optionsMask = 0; - bitmap8 optionsOverride = 1; + OptionsBitmap optionsMask = 0; + OptionsBitmap optionsOverride = 1; } request struct MoveColorTemperatureRequest { - HueMoveMode moveMode = 0; + MoveModeEnum moveMode = 0; int16u rate = 1; int16u colorTemperatureMinimumMireds = 2; int16u colorTemperatureMaximumMireds = 3; - bitmap8 optionsMask = 4; - bitmap8 optionsOverride = 5; + OptionsBitmap optionsMask = 4; + OptionsBitmap optionsOverride = 5; } request struct StepColorTemperatureRequest { - HueStepMode stepMode = 0; + StepModeEnum stepMode = 0; int16u stepSize = 1; int16u transitionTime = 2; int16u colorTemperatureMinimumMireds = 3; int16u colorTemperatureMaximumMireds = 4; - bitmap8 optionsMask = 5; - bitmap8 optionsOverride = 6; + OptionsBitmap optionsMask = 5; + OptionsBitmap optionsOverride = 6; } /** Move to specified hue. */ diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index 6f3e6f62d340e7..cf344db593f46a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -40637,16 +40637,16 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, commandArgs, timedInvokeTimeoutMs); } - public void setActivePresetRequest(DefaultClusterCallback callback, byte[] presetHandle) { + public void setActivePresetRequest(DefaultClusterCallback callback, @Nullable byte[] presetHandle) { setActivePresetRequest(callback, presetHandle, 0); } - public void setActivePresetRequest(DefaultClusterCallback callback, byte[] presetHandle, int timedInvokeTimeoutMs) { + public void setActivePresetRequest(DefaultClusterCallback callback, @Nullable byte[] presetHandle, int timedInvokeTimeoutMs) { final long commandId = 6L; ArrayList elements = new ArrayList<>(); final long presetHandleFieldID = 0L; - BaseTLVType presetHandletlvValue = new ByteArrayType(presetHandle); + BaseTLVType presetHandletlvValue = presetHandle != null ? new ByteArrayType(presetHandle) : new NullType(); elements.add(new StructElement(presetHandleFieldID, presetHandletlvValue)); StructType commandArgs = new StructType(elements); diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt index b9166c12e937a1..6f193e694ef34f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt @@ -504,7 +504,7 @@ class ThermostatCluster(private val controller: MatterController, private val en } suspend fun setActivePresetRequest( - presetHandle: ByteArray, + presetHandle: ByteArray?, timedInvokeTimeout: Duration? = null, ) { val commandId: UInt = 6u @@ -513,7 +513,7 @@ class ThermostatCluster(private val controller: MatterController, private val en tlvWriter.startStructure(AnonymousTag) val TAG_PRESET_HANDLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_PRESET_HANDLE_REQ), presetHandle) + presetHandle?.let { tlvWriter.put(ContextSpecificTag(TAG_PRESET_HANDLE_REQ), presetHandle) } tlvWriter.endStructure() val request: InvokeRequest = diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 82a4a6fe42e669..db775e5d52e5c6 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -32152,7 +32152,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jobject value; std::string valueClassName = "java/lang/Integer"; std::string valueCtorSignature = "(I)V"; - jint jnivalue = static_cast(cppValue); + jint jnivalue = static_cast(cppValue.Raw()); chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, value); return value; @@ -32830,7 +32830,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jobject value; std::string valueClassName = "java/lang/Integer"; std::string valueCtorSignature = "(I)V"; - jint jnivalue = static_cast(cppValue); + jint jnivalue = static_cast(cppValue.Raw()); chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, value); return value; diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index ed3c9154cc8c3a..624f42c8e80088 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -33168,10 +33168,10 @@ class SetActivePresetRequest(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="presetHandle", Tag=0, Type=bytes), + ClusterObjectFieldDescriptor(Label="presetHandle", Tag=0, Type=typing.Union[Nullable, bytes]), ]) - presetHandle: 'bytes' = b"" + presetHandle: 'typing.Union[Nullable, bytes]' = NullValue @dataclass class AtomicResponse(ClusterCommand): @@ -34913,10 +34913,10 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="remainingTime", Tag=0x00000002, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="currentX", Tag=0x00000003, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="currentY", Tag=0x00000004, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="driftCompensation", Tag=0x00000005, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="driftCompensation", Tag=0x00000005, Type=typing.Optional[ColorControl.Enums.DriftCompensationEnum]), ClusterObjectFieldDescriptor(Label="compensationText", Tag=0x00000006, Type=typing.Optional[str]), ClusterObjectFieldDescriptor(Label="colorTemperatureMireds", Tag=0x00000007, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="colorMode", Tag=0x00000008, Type=uint), + ClusterObjectFieldDescriptor(Label="colorMode", Tag=0x00000008, Type=ColorControl.Enums.ColorModeEnum), ClusterObjectFieldDescriptor(Label="options", Tag=0x0000000F, Type=uint), ClusterObjectFieldDescriptor(Label="numberOfPrimaries", Tag=0x00000010, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="primary1X", Tag=0x00000011, Type=typing.Optional[uint]), @@ -34949,7 +34949,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="colorPointBY", Tag=0x0000003B, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="colorPointBIntensity", Tag=0x0000003C, Type=typing.Union[None, Nullable, uint]), ClusterObjectFieldDescriptor(Label="enhancedCurrentHue", Tag=0x00004000, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="enhancedColorMode", Tag=0x00004001, Type=uint), + ClusterObjectFieldDescriptor(Label="enhancedColorMode", Tag=0x00004001, Type=ColorControl.Enums.EnhancedColorModeEnum), ClusterObjectFieldDescriptor(Label="colorLoopActive", Tag=0x00004002, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="colorLoopDirection", Tag=0x00004003, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="colorLoopTime", Tag=0x00004004, Type=typing.Optional[uint]), @@ -34973,10 +34973,10 @@ def descriptor(cls) -> ClusterObjectDescriptor: remainingTime: 'typing.Optional[uint]' = None currentX: 'typing.Optional[uint]' = None currentY: 'typing.Optional[uint]' = None - driftCompensation: 'typing.Optional[uint]' = None + driftCompensation: 'typing.Optional[ColorControl.Enums.DriftCompensationEnum]' = None compensationText: 'typing.Optional[str]' = None colorTemperatureMireds: 'typing.Optional[uint]' = None - colorMode: 'uint' = None + colorMode: 'ColorControl.Enums.ColorModeEnum' = None options: 'uint' = None numberOfPrimaries: 'typing.Union[Nullable, uint]' = None primary1X: 'typing.Optional[uint]' = None @@ -35009,7 +35009,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: colorPointBY: 'typing.Optional[uint]' = None colorPointBIntensity: 'typing.Union[None, Nullable, uint]' = None enhancedCurrentHue: 'typing.Optional[uint]' = None - enhancedColorMode: 'uint' = None + enhancedColorMode: 'ColorControl.Enums.EnhancedColorModeEnum' = None colorLoopActive: 'typing.Optional[uint]' = None colorLoopDirection: 'typing.Optional[uint]' = None colorLoopTime: 'typing.Optional[uint]' = None @@ -35028,7 +35028,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: clusterRevision: 'uint' = None class Enums: - class ColorLoopAction(MatterIntEnum): + class ColorLoopActionEnum(MatterIntEnum): kDeactivate = 0x00 kActivateFromColorLoopStartEnhancedHue = 0x01 kActivateFromEnhancedCurrentHue = 0x02 @@ -35038,28 +35038,28 @@ class ColorLoopAction(MatterIntEnum): # enum value. This specific value should never be transmitted. kUnknownEnumValue = 3, - class ColorLoopDirection(MatterIntEnum): - kDecrementHue = 0x00 - kIncrementHue = 0x01 + class ColorLoopDirectionEnum(MatterIntEnum): + kDecrement = 0x00 + kIncrement = 0x01 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving an unknown # enum value. This specific value should never be transmitted. kUnknownEnumValue = 2, - class ColorMode(MatterIntEnum): + class ColorModeEnum(MatterIntEnum): kCurrentHueAndCurrentSaturation = 0x00 kCurrentXAndCurrentY = 0x01 - kColorTemperature = 0x02 + kColorTemperatureMireds = 0x02 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving an unknown # enum value. This specific value should never be transmitted. kUnknownEnumValue = 3, - class HueDirection(MatterIntEnum): - kShortestDistance = 0x00 - kLongestDistance = 0x01 + class DirectionEnum(MatterIntEnum): + kShortest = 0x00 + kLongest = 0x01 kUp = 0x02 kDown = 0x03 # All received enum values that are not listed above will be mapped @@ -35068,26 +35068,30 @@ class HueDirection(MatterIntEnum): # enum value. This specific value should never be transmitted. kUnknownEnumValue = 4, - class HueMoveMode(MatterIntEnum): - kStop = 0x00 - kUp = 0x01 - kDown = 0x03 + class DriftCompensationEnum(MatterIntEnum): + kNone = 0x00 + kOtherOrUnknown = 0x01 + kTemperatureMonitoring = 0x02 + kOpticalLuminanceMonitoringAndFeedback = 0x03 + kOpticalColorMonitoringAndFeedback = 0x04 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving an unknown # enum value. This specific value should never be transmitted. - kUnknownEnumValue = 2, + kUnknownEnumValue = 5, - class HueStepMode(MatterIntEnum): - kUp = 0x01 - kDown = 0x03 + class EnhancedColorModeEnum(MatterIntEnum): + kCurrentHueAndCurrentSaturation = 0x00 + kCurrentXAndCurrentY = 0x01 + kColorTemperatureMireds = 0x02 + kEnhancedCurrentHueAndCurrentSaturation = 0x03 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving an unknown # enum value. This specific value should never be transmitted. - kUnknownEnumValue = 0, + kUnknownEnumValue = 4, - class SaturationMoveMode(MatterIntEnum): + class MoveModeEnum(MatterIntEnum): kStop = 0x00 kUp = 0x01 kDown = 0x03 @@ -35097,7 +35101,7 @@ class SaturationMoveMode(MatterIntEnum): # enum value. This specific value should never be transmitted. kUnknownEnumValue = 2, - class SaturationStepMode(MatterIntEnum): + class StepModeEnum(MatterIntEnum): kUp = 0x01 kDown = 0x03 # All received enum values that are not listed above will be mapped @@ -35107,18 +35111,12 @@ class SaturationStepMode(MatterIntEnum): kUnknownEnumValue = 0, class Bitmaps: - class ColorCapabilities(IntFlag): - kHueSaturationSupported = 0x1 - kEnhancedHueSupported = 0x2 - kColorLoopSupported = 0x4 - kXYAttributesSupported = 0x8 - kColorTemperatureSupported = 0x10 - - class ColorLoopUpdateFlags(IntFlag): - kUpdateAction = 0x1 - kUpdateDirection = 0x2 - kUpdateTime = 0x4 - kUpdateStartHue = 0x8 + class ColorCapabilitiesBitmap(IntFlag): + kHueSaturation = 0x1 + kEnhancedHue = 0x2 + kColorLoop = 0x4 + kXy = 0x8 + kColorTemperature = 0x10 class Feature(IntFlag): kHueAndSaturation = 0x1 @@ -35127,6 +35125,15 @@ class Feature(IntFlag): kXy = 0x8 kColorTemperature = 0x10 + class OptionsBitmap(IntFlag): + kExecuteIfOff = 0x1 + + class UpdateFlagsBitmap(IntFlag): + kUpdateAction = 0x1 + kUpdateDirection = 0x2 + kUpdateTime = 0x4 + kUpdateStartHue = 0x8 + class Commands: @dataclass class MoveToHue(ClusterCommand): @@ -35140,14 +35147,14 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ ClusterObjectFieldDescriptor(Label="hue", Tag=0, Type=uint), - ClusterObjectFieldDescriptor(Label="direction", Tag=1, Type=ColorControl.Enums.HueDirection), + ClusterObjectFieldDescriptor(Label="direction", Tag=1, Type=ColorControl.Enums.DirectionEnum), ClusterObjectFieldDescriptor(Label="transitionTime", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=4, Type=uint), ]) hue: 'uint' = 0 - direction: 'ColorControl.Enums.HueDirection' = 0 + direction: 'ColorControl.Enums.DirectionEnum' = 0 transitionTime: 'uint' = 0 optionsMask: 'uint' = 0 optionsOverride: 'uint' = 0 @@ -35163,13 +35170,13 @@ class MoveHue(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.HueMoveMode), + ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.MoveModeEnum), ClusterObjectFieldDescriptor(Label="rate", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=3, Type=uint), ]) - moveMode: 'ColorControl.Enums.HueMoveMode' = 0 + moveMode: 'ColorControl.Enums.MoveModeEnum' = 0 rate: 'uint' = 0 optionsMask: 'uint' = 0 optionsOverride: 'uint' = 0 @@ -35185,14 +35192,14 @@ class StepHue(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.HueStepMode), + ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.StepModeEnum), ClusterObjectFieldDescriptor(Label="stepSize", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="transitionTime", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=4, Type=uint), ]) - stepMode: 'ColorControl.Enums.HueStepMode' = 0 + stepMode: 'ColorControl.Enums.StepModeEnum' = 0 stepSize: 'uint' = 0 transitionTime: 'uint' = 0 optionsMask: 'uint' = 0 @@ -35231,13 +35238,13 @@ class MoveSaturation(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.SaturationMoveMode), + ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.MoveModeEnum), ClusterObjectFieldDescriptor(Label="rate", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=3, Type=uint), ]) - moveMode: 'ColorControl.Enums.SaturationMoveMode' = 0 + moveMode: 'ColorControl.Enums.MoveModeEnum' = 0 rate: 'uint' = 0 optionsMask: 'uint' = 0 optionsOverride: 'uint' = 0 @@ -35253,14 +35260,14 @@ class StepSaturation(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.SaturationStepMode), + ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.StepModeEnum), ClusterObjectFieldDescriptor(Label="stepSize", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="transitionTime", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=4, Type=uint), ]) - stepMode: 'ColorControl.Enums.SaturationStepMode' = 0 + stepMode: 'ColorControl.Enums.StepModeEnum' = 0 stepSize: 'uint' = 0 transitionTime: 'uint' = 0 optionsMask: 'uint' = 0 @@ -35394,14 +35401,14 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ ClusterObjectFieldDescriptor(Label="enhancedHue", Tag=0, Type=uint), - ClusterObjectFieldDescriptor(Label="direction", Tag=1, Type=ColorControl.Enums.HueDirection), + ClusterObjectFieldDescriptor(Label="direction", Tag=1, Type=ColorControl.Enums.DirectionEnum), ClusterObjectFieldDescriptor(Label="transitionTime", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=4, Type=uint), ]) enhancedHue: 'uint' = 0 - direction: 'ColorControl.Enums.HueDirection' = 0 + direction: 'ColorControl.Enums.DirectionEnum' = 0 transitionTime: 'uint' = 0 optionsMask: 'uint' = 0 optionsOverride: 'uint' = 0 @@ -35417,13 +35424,13 @@ class EnhancedMoveHue(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.HueMoveMode), + ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.MoveModeEnum), ClusterObjectFieldDescriptor(Label="rate", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=3, Type=uint), ]) - moveMode: 'ColorControl.Enums.HueMoveMode' = 0 + moveMode: 'ColorControl.Enums.MoveModeEnum' = 0 rate: 'uint' = 0 optionsMask: 'uint' = 0 optionsOverride: 'uint' = 0 @@ -35439,14 +35446,14 @@ class EnhancedStepHue(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.HueStepMode), + ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.StepModeEnum), ClusterObjectFieldDescriptor(Label="stepSize", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="transitionTime", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=4, Type=uint), ]) - stepMode: 'ColorControl.Enums.HueStepMode' = 0 + stepMode: 'ColorControl.Enums.StepModeEnum' = 0 stepSize: 'uint' = 0 transitionTime: 'uint' = 0 optionsMask: 'uint' = 0 @@ -35488,8 +35495,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ ClusterObjectFieldDescriptor(Label="updateFlags", Tag=0, Type=uint), - ClusterObjectFieldDescriptor(Label="action", Tag=1, Type=ColorControl.Enums.ColorLoopAction), - ClusterObjectFieldDescriptor(Label="direction", Tag=2, Type=ColorControl.Enums.ColorLoopDirection), + ClusterObjectFieldDescriptor(Label="action", Tag=1, Type=ColorControl.Enums.ColorLoopActionEnum), + ClusterObjectFieldDescriptor(Label="direction", Tag=2, Type=ColorControl.Enums.ColorLoopDirectionEnum), ClusterObjectFieldDescriptor(Label="time", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="startHue", Tag=4, Type=uint), ClusterObjectFieldDescriptor(Label="optionsMask", Tag=5, Type=uint), @@ -35497,8 +35504,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: ]) updateFlags: 'uint' = 0 - action: 'ColorControl.Enums.ColorLoopAction' = 0 - direction: 'ColorControl.Enums.ColorLoopDirection' = 0 + action: 'ColorControl.Enums.ColorLoopActionEnum' = 0 + direction: 'ColorControl.Enums.ColorLoopDirectionEnum' = 0 time: 'uint' = 0 startHue: 'uint' = 0 optionsMask: 'uint' = 0 @@ -35533,7 +35540,7 @@ class MoveColorTemperature(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.HueMoveMode), + ClusterObjectFieldDescriptor(Label="moveMode", Tag=0, Type=ColorControl.Enums.MoveModeEnum), ClusterObjectFieldDescriptor(Label="rate", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="colorTemperatureMinimumMireds", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="colorTemperatureMaximumMireds", Tag=3, Type=uint), @@ -35541,7 +35548,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=5, Type=uint), ]) - moveMode: 'ColorControl.Enums.HueMoveMode' = 0 + moveMode: 'ColorControl.Enums.MoveModeEnum' = 0 rate: 'uint' = 0 colorTemperatureMinimumMireds: 'uint' = 0 colorTemperatureMaximumMireds: 'uint' = 0 @@ -35559,7 +35566,7 @@ class StepColorTemperature(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.HueStepMode), + ClusterObjectFieldDescriptor(Label="stepMode", Tag=0, Type=ColorControl.Enums.StepModeEnum), ClusterObjectFieldDescriptor(Label="stepSize", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="transitionTime", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="colorTemperatureMinimumMireds", Tag=3, Type=uint), @@ -35568,7 +35575,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="optionsOverride", Tag=6, Type=uint), ]) - stepMode: 'ColorControl.Enums.HueStepMode' = 0 + stepMode: 'ColorControl.Enums.StepModeEnum' = 0 stepSize: 'uint' = 0 transitionTime: 'uint' = 0 colorTemperatureMinimumMireds: 'uint' = 0 @@ -35669,9 +35676,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) + return ClusterObjectFieldDescriptor(Type=typing.Optional[ColorControl.Enums.DriftCompensationEnum]) - value: 'typing.Optional[uint]' = None + value: 'typing.Optional[ColorControl.Enums.DriftCompensationEnum]' = None @dataclass class CompensationText(ClusterAttributeDescriptor): @@ -35717,9 +35724,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) + return ClusterObjectFieldDescriptor(Type=ColorControl.Enums.ColorModeEnum) - value: 'uint' = 0 + value: 'ColorControl.Enums.ColorModeEnum' = 0 @dataclass class Options(ClusterAttributeDescriptor): @@ -36245,9 +36252,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) + return ClusterObjectFieldDescriptor(Type=ColorControl.Enums.EnhancedColorModeEnum) - value: 'uint' = 0 + value: 'ColorControl.Enums.EnhancedColorModeEnum' = 0 @dataclass class ColorLoopActive(ClusterAttributeDescriptor): diff --git a/src/darwin/Darwin.xcworkspace/xcshareddata/IDETemplateMacros.plist b/src/darwin/Darwin.xcworkspace/xcshareddata/IDETemplateMacros.plist index 861a74eaf635b0..03de09ad225a13 100644 --- a/src/darwin/Darwin.xcworkspace/xcshareddata/IDETemplateMacros.plist +++ b/src/darwin/Darwin.xcworkspace/xcshareddata/IDETemplateMacros.plist @@ -3,9 +3,8 @@ FILEHEADER - -/** - * Copyright (c) 2023 Project CHIP Authors + /** + * 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. diff --git a/src/darwin/Framework/CHIP/MTRBackwardsCompatShims.h b/src/darwin/Framework/CHIP/MTRBackwardsCompatShims.h index 8903957414fc36..1a183c83def9b5 100644 --- a/src/darwin/Framework/CHIP/MTRBackwardsCompatShims.h +++ b/src/darwin/Framework/CHIP/MTRBackwardsCompatShims.h @@ -159,4 +159,33 @@ typedef NS_ENUM(uint8_t, MTROTASoftwareUpdateRequestorOTAUpdateState) { = 0x08, } MTR_DEPRECATED("Please use MTROTASoftwareUpdateRequestorUpdateState", ios(16.4, 17.2), macos(13.3, 14.2), watchos(9.4, 10.2), tvos(16.4, 17.2)); +/** + * ColorControl used to have HueMoveMode/SaturationMoveMode and HueStepMode/SaturationStepMode that had + * identical values. Those got replaced with MoveModeEnum and StepModeEnum respectively. We codegen + * HueMoveMode and HueStepMode as aliases of MoveModeEnum and StepModeEnum, but we need manual shims for + * SaturationMoveMode and SaturationStepMode. + */ +typedef NS_ENUM(uint8_t, MTRColorControlSaturationMoveMode) { + MTRColorControlSaturationMoveModeStop MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeStop") + = 0x00, + MTRColorControlSaturationMoveModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeUp") + = 0x01, + MTRColorControlSaturationMoveModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeDown") + = 0x03, +} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveMode"); + +typedef NS_ENUM(uint8_t, MTRColorControlSaturationStepMode) { + MTRColorControlSaturationStepModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepModeUp") + = 0x01, + MTRColorControlSaturationStepModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepModeDown") + = 0x03, +} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepMode"); + NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index d8fc52b1a2fc6e..d4027f7725ddeb 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -22,7 +22,6 @@ #import "MTRAttributeSpecifiedCheck.h" #import "MTRBaseClusters.h" #import "MTRBaseDevice_Internal.h" -#import "MTRBaseSubscriptionCallback.h" #import "MTRCluster.h" #import "MTRClusterConstants.h" #import "MTRCommandTimedCheck.h" @@ -43,16 +42,8 @@ #import "zap-generated/MTRCommandPayloads_Internal.h" #import "lib/core/CHIPError.h" -#import "lib/core/DataModelTypes.h" -#import -#import - -#import -#import -#import -#import + #import -#import typedef void (^MTRDeviceAttributeReportHandler)(NSArray * _Nonnull); @@ -64,43 +55,6 @@ // Disabling pending crashes #define ENABLE_CONNECTIVITY_MONITORING 0 -// Consider moving utility classes to their own file -#pragma mark - Utility Classes - -// container of MTRDevice delegate weak reference, its queue, and its interested paths for attribute reports -MTR_DIRECT_MEMBERS -@interface MTRDeviceDelegateInfo : NSObject { -@private - void * _delegatePointerValue; - __weak id _delegate; - dispatch_queue_t _queue; - NSArray * _Nullable _interestedPathsForAttributes; - NSArray * _Nullable _interestedPathsForEvents; -} - -// Array of interested cluster paths, attribute paths, or endpointID, for attribute report filtering. -@property (readonly, nullable) NSArray * interestedPathsForAttributes; - -// Array of interested cluster paths, attribute paths, or endpointID, for event report filtering. -@property (readonly, nullable) NSArray * interestedPathsForEvents; - -// Expose delegate -@property (readonly) id delegate; - -// Pointer value for logging purpose only -@property (readonly) void * delegatePointerValue; - -- (instancetype)initWithDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents; - -// Returns YES if delegate and queue are both non-null, and the block is scheduled to run. -- (BOOL)callDelegateWithBlock:(void (^)(id))block; - -#ifdef DEBUG -// Only used for unit test purposes - normal delegate should not expect or handle being called back synchronously. -- (BOOL)callDelegateSynchronouslyWithBlock:(void (^)(id))block; -#endif -@end - @implementation MTRDeviceDelegateInfo - (instancetype)initWithDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents { @@ -150,85 +104,13 @@ - (void)_deviceInternalStateChanged:(MTRDevice *)device; /* END DRAGONS */ -#pragma mark - SubscriptionCallback class declaration using namespace chip; using namespace chip::app; using namespace chip::Protocols::InteractionModel; using namespace chip::Tracing::DarwinFramework; -typedef void (^FirstReportHandler)(void); - -namespace { - -class SubscriptionCallback final : public MTRBaseSubscriptionCallback { -public: - SubscriptionCallback(DataReportCallback attributeReportCallback, DataReportCallback eventReportCallback, - ErrorCallback errorCallback, MTRDeviceResubscriptionScheduledHandler resubscriptionCallback, - SubscriptionEstablishedHandler subscriptionEstablishedHandler, OnDoneHandler onDoneHandler, - UnsolicitedMessageFromPublisherHandler unsolicitedMessageFromPublisherHandler, ReportBeginHandler reportBeginHandler, - ReportEndHandler reportEndHandler) - : MTRBaseSubscriptionCallback(attributeReportCallback, eventReportCallback, errorCallback, resubscriptionCallback, - subscriptionEstablishedHandler, onDoneHandler, unsolicitedMessageFromPublisherHandler, reportBeginHandler, - reportEndHandler) - { - } - - // Used to reset Resubscription backoff on events that indicate likely availability of device to come back online - void ResetResubscriptionBackoff() { mResubscriptionNumRetries = 0; } - -private: - void OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus) override; - - void OnAttributeData(const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const StatusIB & aStatus) override; - - CHIP_ERROR OnResubscriptionNeeded(chip::app::ReadClient * apReadClient, CHIP_ERROR aTerminationCause) override; - - // Copied from ReadClient and customized for MTRDevice resubscription time reset - uint32_t ComputeTimeTillNextSubscription(); - uint32_t mResubscriptionNumRetries = 0; -}; - -} // anonymous namespace - #pragma mark - MTRDevice -// Utility methods for working with MTRInternalDeviceState, located near the -// enum so it's easier to notice that they need to stay in sync. -namespace { -bool HadSubscriptionEstablishedOnce(MTRInternalDeviceState state) -{ - return state >= MTRInternalDeviceStateInitialSubscriptionEstablished; -} - -bool NeedToStartSubscriptionSetup(MTRInternalDeviceState state) -{ - return state <= MTRInternalDeviceStateUnsubscribed; -} - -bool HaveSubscriptionEstablishedRightNow(MTRInternalDeviceState state) -{ - return state == MTRInternalDeviceStateInitialSubscriptionEstablished || state == MTRInternalDeviceStateLaterSubscriptionEstablished; -} - -NSString * InternalDeviceStateString(MTRInternalDeviceState state) -{ - switch (state) { - case MTRInternalDeviceStateUnsubscribed: - return @"Unsubscribed"; - case MTRInternalDeviceStateSubscribing: - return @"Subscribing"; - case MTRInternalDeviceStateInitialSubscriptionEstablished: - return @"InitialSubscriptionEstablished"; - case MTRInternalDeviceStateResubscribing: - return @"Resubscribing"; - case MTRInternalDeviceStateLaterSubscriptionEstablished: - return @"LaterSubscriptionEstablished"; - default: - return @"Unknown"; - } -} -} // anonymous namespace - typedef NS_ENUM(NSUInteger, MTRDeviceExpectedValueFieldIndex) { MTRDeviceExpectedValueFieldExpirationTimeIndex = 0, MTRDeviceExpectedValueFieldValueIndex = 1, @@ -371,7 +253,6 @@ - (BOOL)isEqual:(id)object #define MTRDEVICE_SUBSCRIPTION_LATENCY_NEW_VALUE_WEIGHT (1.0 / 3.0) @interface MTRDevice () -@property (nonatomic, readonly) os_unfair_lock lock; // protects the caches and device state // protects against concurrent time updates by guarding timeUpdateScheduled flag which manages time updates scheduling, // and protects device calls to setUTCTime and setDSTOffset. This can't just be replaced with "lock", because the time // update code calls public APIs like readAttributeWithEndpointID:.. (which attempt to take "lock") while holding @@ -393,13 +274,6 @@ @interface MTRDevice () #define MTRDEVICE_SUBSCRIPTION_ATTEMPT_MAX_WAIT_SECONDS (3600) @property (nonatomic) uint32_t lastSubscriptionAttemptWait; -/** - * If reattemptingSubscription is true, that means that we have failed to get a - * CASE session for the publisher and are now waiting to try again. In this - * state we never have subscriptionActive true or a non-null currentReadClient. - */ -@property (nonatomic) BOOL reattemptingSubscription; - // Expected value cache is attributePath => NSArray of [NSDate of expiration time, NSDictionary of value, expected value ID] // - See MTRDeviceExpectedValueFieldIndex for the definitions of indices into this array. // See MTRDeviceResponseHandler definition for value dictionary details. @@ -417,14 +291,6 @@ @interface MTRDevice () @property (nonatomic) NSMutableDictionary * temporaryMetaDataCache; -/** - * If currentReadClient is non-null, that means that we successfully - * called SendAutoResubscribeRequest on the ReadClient and have not yet gotten - * an OnDone for that ReadClient. - */ -@property (nonatomic) ReadClient * currentReadClient; -@property (nonatomic) SubscriptionCallback * currentSubscriptionCallback; // valid when and only when currentReadClient is valid - @end // Declaring selector so compiler won't complain about testing and calling it in _handleReportEnd @@ -444,10 +310,6 @@ - (BOOL)unitTestSuppressTimeBasedReachabilityChanges:(MTRDevice *)device; #endif @implementation MTRDevice { -#ifdef DEBUG - NSUInteger _unitTestAttributesReportedSinceLastCheck; -#endif - // _deviceCachePrimed is true if we have the data that comes from an initial // subscription priming report (whether it came from storage or from our // subscription). @@ -465,26 +327,10 @@ @implementation MTRDevice { // right now (because they have been evicted). NSMutableSet * _persistedClusters; - // When we last failed to subscribe to the device (either via - // _setupSubscriptionWithReason or via the auto-resubscribe behavior - // of the ReadClient). Nil if we have had no such failures. - NSDate * _Nullable _lastSubscriptionFailureTime; - MTRDeviceConnectivityMonitor * _connectivityMonitor; - // This boolean keeps track of any device configuration changes received in an attribute report. // If this is true when the report ends, we notify the delegate. BOOL _deviceConfigurationChanged; - // The completion block is set when the subscription / resubscription work is enqueued, and called / cleared when any of the following happen: - // 1. Subscription establishes - // 2. OnResubscriptionNeeded is called - // 3. Subscription reset (including when getSessionForNode fails) - MTRAsyncWorkCompletionBlock _subscriptionPoolWorkCompletionBlock; - - // Tracking of initial subscribe latency. When _initialSubscribeStart is - // nil, we are not tracking the latency. - NSDate * _Nullable _initialSubscribeStart; - // Storage behavior configuration and variables to keep track of the logic // _clusterDataPersistenceFirstScheduledTime is used to track the start time of the delay between // report and persistence. @@ -502,8 +348,6 @@ @implementation MTRDevice { // System time change observer reference id _systemTimeChangeObserverToken; - NSMutableSet * _delegates; - // Protects mutable state used by our description getter. This is a separate lock from "lock" // so that we don't need to worry about getting our description while holding "lock" (e.g due to // logging self). This lock _must_ be held narrowly, with no other lock acquisitions allowed @@ -516,20 +360,17 @@ @implementation MTRDevice { // _allNetworkFeatures is a bitwise or of the feature maps of all network commissioning clusters // present on the device, or nil if there aren't any. NSNumber * _Nullable _allNetworkFeatures; - // Copy of _internalDeviceState that is safe to use in description. - MTRInternalDeviceState _internalDeviceStateForDescription; - // Copy of _lastSubscriptionAttemptWait that is safe to use in description. - uint32_t _lastSubscriptionAttemptWaitForDescription; // Most recent entry in _mostRecentReportTimes, if any. NSDate * _Nullable _mostRecentReportTimeForDescription; - // Copy of _lastSubscriptionFailureTime that is safe to use in description. - NSDate * _Nullable _lastSubscriptionFailureTimeForDescription; } -- (instancetype)initForSubclasses +- (instancetype)initForSubclassesWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller { if (self = [super init]) { - // nothing, as superclass of MTRDevice is NSObject + _lock = OS_UNFAIR_LOCK_INIT; + _delegates = [NSMutableSet set]; + _deviceController = controller; + _nodeID = nodeID; } return self; @@ -550,7 +391,6 @@ - (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceControlle _asyncWorkQueue = [[MTRAsyncWorkQueue alloc] initWithContext:self]; _state = MTRDeviceStateUnknown; _internalDeviceState = MTRInternalDeviceStateUnsubscribed; - _internalDeviceStateForDescription = MTRInternalDeviceStateUnsubscribed; if (controller.controllerDataStore) { _persistedClusterData = [[NSCache alloc] init]; } else { @@ -585,62 +425,6 @@ - (void)dealloc MTR_LOG("MTRDevice dealloc: %p", self); } -- (NSString *)description -{ - id _Nullable vid; - id _Nullable pid; - NSNumber * _Nullable networkFeatures; - MTRInternalDeviceState internalDeviceState; - uint32_t lastSubscriptionAttemptWait; - NSDate * _Nullable mostRecentReportTime; - NSDate * _Nullable lastSubscriptionFailureTime; - { - std::lock_guard lock(_descriptionLock); - vid = _vid; - pid = _pid; - networkFeatures = _allNetworkFeatures; - internalDeviceState = _internalDeviceStateForDescription; - lastSubscriptionAttemptWait = _lastSubscriptionAttemptWaitForDescription; - mostRecentReportTime = _mostRecentReportTimeForDescription; - lastSubscriptionFailureTime = _lastSubscriptionFailureTimeForDescription; - } - - if (vid == nil) { - vid = @"Unknown"; - } - - if (pid == nil) { - pid = @"Unknown"; - } - - NSString * wifi; - NSString * thread; - if (networkFeatures == nil) { - wifi = @"NO"; - thread = @"NO"; - } else { - wifi = YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureWiFiNetworkInterface); - thread = YES_NO(networkFeatures.unsignedLongLongValue & MTRNetworkCommissioningFeatureThreadNetworkInterface); - } - - NSString * reportAge; - if (mostRecentReportTime) { - reportAge = [NSString stringWithFormat:@" (%.0lfs ago)", -[mostRecentReportTime timeIntervalSinceNow]]; - } else { - reportAge = @""; - } - - NSString * subscriptionFailureAge; - if (lastSubscriptionFailureTime) { - subscriptionFailureAge = [NSString stringWithFormat:@" (%.0lfs ago)", -[lastSubscriptionFailureTime timeIntervalSinceNow]]; - } else { - subscriptionFailureAge = @""; - } - - return [NSString - stringWithFormat:@"", self, _deviceController.compressedFabricID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, vid, pid, wifi, thread, InternalDeviceStateString(internalDeviceState), static_cast(lastSubscriptionAttemptWait), static_cast(_asyncWorkQueue.itemCount), mostRecentReportTime, reportAge, lastSubscriptionFailureTime, subscriptionFailureAge, _deviceController.uniqueIdentifier]; -} - + (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller { return [controller deviceForNodeID:nodeID]; @@ -875,6 +659,8 @@ - (BOOL)_subscriptionsAllowed { os_unfair_lock_assert_owner(&self->_lock); + // TODO: XPC: This function and all its callsites should go away from this class. + // We should not allow a subscription for device controllers over XPC. return ![_deviceController isKindOfClass:MTRDeviceControllerOverXPC.class]; } @@ -923,34 +709,14 @@ - (void)_addDelegate:(id)delegate queue:(dispatch_queue_t)que [_delegates addObject:newDelegateInfo]; MTR_LOG("%@ added delegate info %@", self, newDelegateInfo); - __block BOOL shouldSetUpSubscription = [self _subscriptionsAllowed]; - - // For unit testing only. If this ever changes to not being for unit testing purposes, - // we would need to move the code outside of where we acquire the lock above. -#ifdef DEBUG - [self _callFirstDelegateSynchronouslyWithBlock:^(id testDelegate) { - if ([testDelegate respondsToSelector:@selector(unitTestShouldSetUpSubscriptionForDevice:)]) { - shouldSetUpSubscription = [testDelegate unitTestShouldSetUpSubscriptionForDevice:self]; - } - }]; -#endif + // Call hook to allow subclasses to act on delegate addition. + [self _delegateAdded]; +} - if (shouldSetUpSubscription) { - MTR_LOG("%@ - starting subscription setup", self); - // Record the time of first addDelegate call that triggers initial subscribe, and do not reset this value on subsequent addDelegate calls - if (!_initialSubscribeStart) { - _initialSubscribeStart = [NSDate now]; - } - if ([self _deviceUsesThread]) { - MTR_LOG(" => %@ - device is a thread device, scheduling in pool", self); - [self _scheduleSubscriptionPoolWork:^{ - std::lock_guard lock(self->_lock); - [self _setupSubscriptionWithReason:@"delegate is set and scheduled subscription is happening"]; - } inNanoseconds:0 description:@"MTRDevice setDelegate first subscription"]; - } else { - [self _setupSubscriptionWithReason:@"delegate is set and subscription is needed"]; - } - } +- (void)_delegateAdded +{ + // Nothing to do; this is a hook for subclasses. If that ever changes for + // some reason, subclasses need to start calling this hook on their super. } - (void)removeDelegate:(id)delegate @@ -962,7 +728,10 @@ - (void)removeDelegate:(id)delegate NSMutableSet * delegatesToRemove = [NSMutableSet set]; [self _iterateDelegatesWithBlock:^(MTRDeviceDelegateInfo * delegateInfo) { id strongDelegate = delegateInfo.delegate; - if (strongDelegate == delegate) { + if (!strongDelegate) { + [delegatesToRemove addObject:delegateInfo]; + MTR_LOG("%@ removing delegate info for nil delegate %p", self, delegateInfo.delegatePointerValue); + } else if (strongDelegate == delegate) { [delegatesToRemove addObject:delegateInfo]; MTR_LOG("%@ removing delegate info %@ for %p", self, delegateInfo, delegate); } @@ -976,45 +745,9 @@ - (void)removeDelegate:(id)delegate - (void)invalidate { - MTR_LOG("%@ invalidate", self); - - [_asyncWorkQueue invalidate]; - - os_unfair_lock_lock(&self->_timeSyncLock); - _timeUpdateScheduled = NO; - os_unfair_lock_unlock(&self->_timeSyncLock); - - os_unfair_lock_lock(&self->_lock); - - _state = MTRDeviceStateUnknown; + std::lock_guard lock(_lock); [_delegates removeAllObjects]; - - // Make sure we don't try to resubscribe if we have a pending resubscribe - // attempt, since we now have no delegate. - _reattemptingSubscription = NO; - - [_deviceController asyncDispatchToMatterQueue:^{ - MTR_LOG("%@ invalidate disconnecting ReadClient and SubscriptionCallback", self); - - // Destroy the read client and callback (has to happen on the Matter - // queue, to avoid deleting objects that are being referenced), to - // tear down the subscription. We will get no more callbacks from - // the subscription after this point. - std::lock_guard lock(self->_lock); - self->_currentReadClient = nullptr; - if (self->_currentSubscriptionCallback) { - delete self->_currentSubscriptionCallback; - } - self->_currentSubscriptionCallback = nullptr; - - [self _changeInternalState:MTRInternalDeviceStateUnsubscribed]; - } - errorHandler:nil]; - - [self _stopConnectivityMonitoring]; - - os_unfair_lock_unlock(&self->_lock); } - (void)nodeMayBeAdvertisingOperational @@ -1022,51 +755,6 @@ - (void)nodeMayBeAdvertisingOperational assertChipStackLockedByCurrentThread(); MTR_LOG("%@ saw new operational advertisement", self); - - [self _triggerResubscribeWithReason:@"operational advertisement seen" - nodeLikelyReachable:YES]; -} - -// Trigger a resubscribe as needed. nodeLikelyReachable should be YES if we -// have reason to suspect the node is now reachable, NO if we have no idea -// whether it might be. -- (void)_triggerResubscribeWithReason:(NSString *)reason nodeLikelyReachable:(BOOL)nodeLikelyReachable -{ - MTR_LOG("%@ _triggerResubscribeWithReason called with reason %@", self, reason); - assertChipStackLockedByCurrentThread(); - - // We might want to trigger a resubscribe on our existing ReadClient. Do - // that outside the scope of our lock, so we're not calling arbitrary code - // we don't control with the lock held. This is safe, because we are - // running on he Matter queue and the ReadClient can't get destroyed while - // we are on that queue. - ReadClient * readClientToResubscribe = nullptr; - SubscriptionCallback * subscriptionCallback = nullptr; - - os_unfair_lock_lock(&self->_lock); - - // Don't change state to MTRDeviceStateReachable, since the device might not - // in fact be reachable yet; we won't know until we have managed to - // establish a CASE session. And at that point, our subscription will - // trigger the state change as needed. - if (self.reattemptingSubscription) { - [self _reattemptSubscriptionNowIfNeededWithReason:reason]; - } else { - readClientToResubscribe = self->_currentReadClient; - subscriptionCallback = self->_currentSubscriptionCallback; - } - os_unfair_lock_unlock(&self->_lock); - - if (readClientToResubscribe) { - if (nodeLikelyReachable) { - // If we have reason to suspect the node is now reachable, reset the - // backoff timer, so that if this attempt fails we'll try again - // quickly; it's possible we'll just catch the node at a bad time - // here (e.g. still booting up), but should try again reasonably quickly. - subscriptionCallback->ResetResubscriptionBackoff(); - } - readClientToResubscribe->TriggerResubscribeIfScheduled(reason.UTF8String); - } } // Return YES if we are in a state where, apart from communication issues with @@ -1102,41 +790,6 @@ - (BOOL)_subscriptionAbleToReport // Notification that read-through was skipped for an attribute read. - (void)_readThroughSkipped { - std::lock_guard lock(_lock); - if (_state == MTRDeviceStateReachable) { - // We're getting reports from the device, so there's nothing else to be - // done here. We could skip this check, because our "try to - // resubscribe" code would be a no-op in this case, but then we'd have - // an extra dispatch in the common case of read-while-subscribed, which - // is not great for peformance. - return; - } - - if (_lastSubscriptionFailureTime == nil) { - // No need to try to do anything here, because we have never failed a - // subscription attempt (so we might be in the middle of one now, and no - // need to prod things along). - return; - } - - if ([[NSDate now] timeIntervalSinceDate:_lastSubscriptionFailureTime] < MTRDEVICE_MIN_RESUBSCRIBE_DUE_TO_READ_INTERVAL_SECONDS) { - // Not enough time has passed since we last tried. Don't create extra - // network traffic. - // - // TODO: Do we need to worry about this being too spammy in the log if - // we keep getting reads while not subscribed? We could add another - // backoff timer or counter for the log line... - MTR_LOG_DEBUG("%@ skipping resubscribe from skipped read-through: not enough time has passed since %@", self, _lastSubscriptionFailureTime); - return; - } - - // Do the remaining work on the Matter queue, because we may want to touch - // ReadClient in there. If the dispatch fails, that's fine; it means our - // controller has shut down, so nothing to be done. - [_deviceController asyncDispatchToMatterQueue:^{ - [self _triggerResubscribeWithReason:@"read-through skipped while not subscribed" nodeLikelyReachable:NO]; - } - errorHandler:nil]; } - (BOOL)_delegateExists @@ -1145,8 +798,7 @@ - (BOOL)_delegateExists return [self _iterateDelegatesWithBlock:nil]; } -// Returns YES if any non-null delegates were found -- (BOOL)_iterateDelegatesWithBlock:(void(NS_NOESCAPE ^)(MTRDeviceDelegateInfo * delegateInfo)_Nullable)block +- (BOOL)_iterateDelegatesWithBlock:(void(NS_NOESCAPE ^ _Nullable)(MTRDeviceDelegateInfo * delegateInfo))block { os_unfair_lock_assert_owner(&self->_lock); @@ -1196,9 +848,14 @@ - (BOOL)_callDelegatesWithBlock:(void (^)(id delegate))block return (delegatesCalled > 0); } +- (BOOL)_lockAndCallDelegatesWithBlock:(void (^)(id delegate))block +{ + std::lock_guard lock(self->_lock); + return [self _callDelegatesWithBlock:block]; +} + #ifdef DEBUG // Only used for unit test purposes - normal delegate should not expect or handle being called back synchronously -// Returns YES if a delegate is called - (void)_callFirstDelegateSynchronouslyWithBlock:(void (^)(id delegate))block { os_unfair_lock_assert_owner(&self->_lock); @@ -1247,29 +904,6 @@ - (void)_changeState:(MTRDeviceState)state } } -- (void)_changeInternalState:(MTRInternalDeviceState)state -{ - os_unfair_lock_assert_owner(&self->_lock); - MTRInternalDeviceState lastState = _internalDeviceState; - _internalDeviceState = state; - { - std::lock_guard lock(_descriptionLock); - _internalDeviceStateForDescription = _internalDeviceState; - } - if (lastState != state) { - MTR_LOG("%@ internal state change %lu => %lu", self, static_cast(lastState), static_cast(state)); - - /* BEGIN DRAGONS: This is a huge hack for a specific use case, do not rename, remove or modify behavior here */ - // TODO: This should only be called for thread devices - [self _callDelegatesWithBlock:^(id delegate) { - if ([delegate respondsToSelector:@selector(_deviceInternalStateChanged:)]) { - [delegate _deviceInternalStateChanged:self]; - } - }]; - /* END DRAGONS */ - } -} - #ifdef DEBUG - (MTRInternalDeviceState)_getInternalState { @@ -1278,71 +912,6 @@ - (MTRInternalDeviceState)_getInternalState } #endif -// First Time Sync happens 2 minutes after reachability (this can be changed in the future) -#define MTR_DEVICE_TIME_UPDATE_INITIAL_WAIT_TIME_SEC (60 * 2) -- (void)_handleSubscriptionEstablished -{ - os_unfair_lock_lock(&self->_lock); - - // If subscription had reset since this handler was scheduled, do not execute "established" logic below - if (!HaveSubscriptionEstablishedRightNow(_internalDeviceState)) { - MTR_LOG("%@ _handleSubscriptionEstablished run with internal state %lu - skipping subscription establishment logic", self, static_cast(_internalDeviceState)); - return; - } - - // We have completed the subscription work - remove from the subscription pool. - [self _clearSubscriptionPoolWork]; - - // No need to monitor connectivity after subscription establishment - [self _stopConnectivityMonitoring]; - - // reset subscription attempt wait time when subscription succeeds - [self _setLastSubscriptionAttemptWait:0]; - - auto initialSubscribeStart = _initialSubscribeStart; - // We no longer need to track subscribe latency for this device. - _initialSubscribeStart = nil; - - if (initialSubscribeStart != nil) { - // We want time interval from initialSubscribeStart to now, not the other - // way around. - NSTimeInterval subscriptionLatency = -[initialSubscribeStart timeIntervalSinceNow]; - if (_estimatedSubscriptionLatency == nil) { - _estimatedSubscriptionLatency = @(subscriptionLatency); - } else { - NSTimeInterval newSubscriptionLatencyEstimate = MTRDEVICE_SUBSCRIPTION_LATENCY_NEW_VALUE_WEIGHT * subscriptionLatency + (1 - MTRDEVICE_SUBSCRIPTION_LATENCY_NEW_VALUE_WEIGHT) * _estimatedSubscriptionLatency.doubleValue; - _estimatedSubscriptionLatency = @(newSubscriptionLatencyEstimate); - } - [self _storePersistedDeviceData]; - } - - os_unfair_lock_unlock(&self->_lock); - - os_unfair_lock_lock(&self->_timeSyncLock); - - if (!self.timeUpdateScheduled) { - [self _scheduleNextUpdate:MTR_DEVICE_TIME_UPDATE_INITIAL_WAIT_TIME_SEC]; - } - - os_unfair_lock_unlock(&self->_timeSyncLock); -} - -- (void)_handleSubscriptionError:(NSError *)error -{ - std::lock_guard lock(_lock); - [self _doHandleSubscriptionError:error]; -} - -- (void)_doHandleSubscriptionError:(NSError *)error -{ - os_unfair_lock_assert_owner(&_lock); - - [self _changeInternalState:MTRInternalDeviceStateUnsubscribed]; - _unreportedEvents = nil; - - [self _changeState:MTRDeviceStateUnreachable]; -} - - (BOOL)deviceUsesThread { std::lock_guard lock(_lock); @@ -1386,253 +955,6 @@ - (BOOL)_deviceUsesThread return (networkCommissioningClusterFeatureMapValue & MTRNetworkCommissioningFeatureThreadNetworkInterface) != 0 ? YES : NO; } -- (void)_clearSubscriptionPoolWork -{ - os_unfair_lock_assert_owner(&self->_lock); - MTRAsyncWorkCompletionBlock completion = self->_subscriptionPoolWorkCompletionBlock; - if (completion) { -#ifdef DEBUG - [self _callDelegatesWithBlock:^(id testDelegate) { - if ([testDelegate respondsToSelector:@selector(unitTestSubscriptionPoolWorkComplete:)]) { - [testDelegate unitTestSubscriptionPoolWorkComplete:self]; - } - }]; -#endif - self->_subscriptionPoolWorkCompletionBlock = nil; - completion(MTRAsyncWorkComplete); - } -} - -- (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:(int64_t)inNanoseconds description:(NSString *)description -{ - os_unfair_lock_assert_owner(&self->_lock); - - // Sanity check we are not scheduling for this device multiple times in the pool - if (_subscriptionPoolWorkCompletionBlock) { - MTR_LOG("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description); - return; - } - - // Wait the required amount of time, then put it in the subscription pool to wait additionally for a spot, if needed - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, inNanoseconds), dispatch_get_main_queue(), ^{ - // In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op - MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc] initWithQueue:self.queue]; - [workItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) { - MTR_LOG("%@ - work item is ready to attempt pooled subscription", self); - os_unfair_lock_lock(&self->_lock); -#ifdef DEBUG - [self _callDelegatesWithBlock:^(id testDelegate) { - if ([testDelegate respondsToSelector:@selector(unitTestSubscriptionPoolDequeue:)]) { - [testDelegate unitTestSubscriptionPoolDequeue:self]; - } - }]; -#endif - if (self->_subscriptionPoolWorkCompletionBlock) { - // This means a resubscription triggering event happened and is now in-progress - MTR_LOG("%@ timer fired but already running in subscription pool - ignoring: %@", self, description); - os_unfair_lock_unlock(&self->_lock); - - // call completion as complete to remove from queue - completion(MTRAsyncWorkComplete); - return; - } - - // Otherwise, save the completion block - self->_subscriptionPoolWorkCompletionBlock = completion; - os_unfair_lock_unlock(&self->_lock); - - workBlock(); - }]; - [self->_deviceController.concurrentSubscriptionPool enqueueWorkItem:workItem description:description]; - MTR_LOG("%@ - enqueued in the subscription pool", self); - }); -} - -- (void)_handleResubscriptionNeededWithDelay:(NSNumber *)resubscriptionDelayMs -{ - BOOL deviceUsesThread; - - os_unfair_lock_lock(&self->_lock); - - [self _changeState:MTRDeviceStateUnknown]; - [self _changeInternalState:MTRInternalDeviceStateResubscribing]; - - // If we are here, then the ReadClient either just detected a subscription - // drop or just tried again and failed. Either way, count it as "tried and - // failed to subscribe": in the latter case it's actually true, and in the - // former case we recently had a subscription and do not want to be forcing - // retries immediately. - _lastSubscriptionFailureTime = [NSDate now]; - { - std::lock_guard lock(_descriptionLock); - _lastSubscriptionFailureTimeForDescription = _lastSubscriptionFailureTime; - } - - deviceUsesThread = [self _deviceUsesThread]; - - // If a previous resubscription failed, remove the item from the subscription pool. - [self _clearSubscriptionPoolWork]; - - os_unfair_lock_unlock(&self->_lock); - - // Use the existing _triggerResubscribeWithReason mechanism, which does the right checks when - // this block is run -- if other triggering events had happened, this would become a no-op. - auto resubscriptionBlock = ^{ - [self->_deviceController asyncDispatchToMatterQueue:^{ - [self _triggerResubscribeWithReason:@"ResubscriptionNeeded timer fired" nodeLikelyReachable:NO]; - } errorHandler:^(NSError * _Nonnull error) { - // If controller is not running, clear work item from the subscription queue - MTR_LOG_ERROR("%@ could not dispatch to matter queue for resubscription - error %@", self, error); - std::lock_guard lock(self->_lock); - [self _clearSubscriptionPoolWork]; - }]; - }; - - int64_t resubscriptionDelayNs = static_cast(resubscriptionDelayMs.unsignedIntValue * NSEC_PER_MSEC); - if (deviceUsesThread) { - std::lock_guard lock(_lock); - // For Thread-enabled devices, schedule the _triggerResubscribeWithReason call to run in the subscription pool - [self _scheduleSubscriptionPoolWork:resubscriptionBlock inNanoseconds:resubscriptionDelayNs description:@"ReadClient resubscription"]; - } else { - // For non-Thread-enabled devices, just call the resubscription block after the specified time - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, resubscriptionDelayNs), self.queue, resubscriptionBlock); - } - - // Set up connectivity monitoring in case network routability changes for the positive, to accelerate resubscription - [self _setupConnectivityMonitoring]; -} - -- (void)_handleSubscriptionReset:(NSNumber * _Nullable)retryDelay -{ - std::lock_guard lock(_lock); - [self _doHandleSubscriptionReset:retryDelay]; -} - -- (void)_setLastSubscriptionAttemptWait:(uint32_t)lastSubscriptionAttemptWait -{ - os_unfair_lock_assert_owner(&_lock); - _lastSubscriptionAttemptWait = lastSubscriptionAttemptWait; - - std::lock_guard lock(_descriptionLock); - _lastSubscriptionAttemptWaitForDescription = lastSubscriptionAttemptWait; -} - -- (void)_doHandleSubscriptionReset:(NSNumber * _Nullable)retryDelay -{ - os_unfair_lock_assert_owner(&_lock); - - // If we are here, then either we failed to establish initial CASE, or we - // failed to send the initial SubscribeRequest message, or our ReadClient - // has given up completely. Those all count as "we have tried and failed to - // subscribe". - _lastSubscriptionFailureTime = [NSDate now]; - { - std::lock_guard lock(_descriptionLock); - _lastSubscriptionFailureTimeForDescription = _lastSubscriptionFailureTime; - } - - // if there is no delegate then also do not retry - if (![self _delegateExists]) { - // NOTE: Do not log anything here: we have been invalidated, and the - // Matter stack might already be torn down. - return; - } - - // don't schedule multiple retries - if (self.reattemptingSubscription) { - return; - } - - self.reattemptingSubscription = YES; - - NSTimeInterval secondsToWait; - if (_lastSubscriptionAttemptWait < MTRDEVICE_SUBSCRIPTION_ATTEMPT_MIN_WAIT_SECONDS) { - _lastSubscriptionAttemptWait = MTRDEVICE_SUBSCRIPTION_ATTEMPT_MIN_WAIT_SECONDS; - secondsToWait = _lastSubscriptionAttemptWait; - } else if (retryDelay != nil) { - // The device responded but is currently busy. Reset our backoff - // counter, so that we don't end up waiting for a long time if the next - // attempt fails for some reason, and retry after whatever time period - // the device told us to use. - [self _setLastSubscriptionAttemptWait:0]; - secondsToWait = retryDelay.doubleValue; - MTR_LOG("%@ resetting resubscribe attempt counter, and delaying by the server-provided delay: %f", - self, secondsToWait); - } else { - auto lastSubscriptionAttemptWait = _lastSubscriptionAttemptWait * 2; - if (lastSubscriptionAttemptWait > MTRDEVICE_SUBSCRIPTION_ATTEMPT_MAX_WAIT_SECONDS) { - lastSubscriptionAttemptWait = MTRDEVICE_SUBSCRIPTION_ATTEMPT_MAX_WAIT_SECONDS; - } - [self _setLastSubscriptionAttemptWait:lastSubscriptionAttemptWait]; - secondsToWait = lastSubscriptionAttemptWait; - } - - MTR_LOG("%@ scheduling to reattempt subscription in %f seconds", self, secondsToWait); - - // If we started subscription or session establishment but failed, remove item from the subscription pool so we can re-queue. - [self _clearSubscriptionPoolWork]; - - // Call _reattemptSubscriptionNowIfNeededWithReason when timer fires - if subscription is - // in a better state at that time this will be a no-op. - auto resubscriptionBlock = ^{ - std::lock_guard lock(self->_lock); - [self _reattemptSubscriptionNowIfNeededWithReason:@"got subscription reset"]; - }; - - int64_t resubscriptionDelayNs = static_cast(secondsToWait * NSEC_PER_SEC); - if ([self _deviceUsesThread]) { - // For Thread-enabled devices, schedule the _reattemptSubscriptionNowIfNeededWithReason call to run in the subscription pool - [self _scheduleSubscriptionPoolWork:resubscriptionBlock inNanoseconds:resubscriptionDelayNs description:@"MTRDevice resubscription"]; - } else { - // For non-Thread-enabled devices, just call the resubscription block after the specified time - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, resubscriptionDelayNs), self.queue, resubscriptionBlock); - } -} - -- (void)_reattemptSubscriptionNowIfNeededWithReason:(NSString *)reason -{ - os_unfair_lock_assert_owner(&self->_lock); - if (!self.reattemptingSubscription) { - return; - } - - MTR_LOG("%@ reattempting subscription with reason %@", self, reason); - self.reattemptingSubscription = NO; - [self _setupSubscriptionWithReason:reason]; -} - -- (void)_handleUnsolicitedMessageFromPublisher -{ - std::lock_guard lock(_lock); - - [self _changeState:MTRDeviceStateReachable]; - - [self _callDelegatesWithBlock:^(id delegate) { - if ([delegate respondsToSelector:@selector(deviceBecameActive:)]) { - [delegate deviceBecameActive:self]; - } - }]; - - // in case this is called during exponential back off of subscription - // reestablishment, this starts the attempt right away - // TODO: This doesn't really make sense. If we _don't_ have a live - // ReadClient how did we get this notification and if we _do_ have an active - // ReadClient, this call or _setupSubscriptionWithReason would be no-ops. - [self _reattemptSubscriptionNowIfNeededWithReason:@"got unsolicited message from publisher"]; -} - -- (void)_markDeviceAsUnreachableIfNeverSubscribed -{ - os_unfair_lock_assert_owner(&self->_lock); - - if (HadSubscriptionEstablishedOnce(_internalDeviceState)) { - return; - } - - MTR_LOG("%@ still not subscribed, marking the device as unreachable", self); - [self _changeState:MTRDeviceStateUnreachable]; -} - - (void)_handleReportBegin { std::lock_guard lock(_lock); @@ -1644,7 +966,7 @@ - (void)_handleReportBegin // If we currently don't have an established subscription, this must be a // priming report. - _receivingPrimingReport = !HaveSubscriptionEstablishedRightNow(_internalDeviceState); + _receivingPrimingReport = YES; } - (NSDictionary *)_clusterDataToPersistSnapshot @@ -2293,8 +1615,6 @@ - (nullable MTRDeviceClusterData *)_clusterDataForPath:(MTRClusterPath *)cluster // First make sure _persistedClusters is consistent with storage, so repeated calls don't immediately re-trigger this [self _reconcilePersistedClustersWithStorage]; - - [self _resetSubscriptionWithReasonString:[NSString stringWithFormat:@"Data store has no data for cluster %@", clusterPath]]; } return data; @@ -2400,350 +1720,16 @@ - (void)_removeCachedAttribute:(NSNumber *)attributeID fromCluster:(MTRClusterPa [clusterData removeValueForAttribute:attributeID]; } -- (void)_createDataVersionFilterListFromDictionary:(NSDictionary *)dataVersions dataVersionFilterList:(DataVersionFilter **)dataVersionFilterList count:(size_t *)count -{ - size_t dataVersionFilterSize = dataVersions.count; - - // Check if any filter list should be generated - if (dataVersionFilterSize == 0) { - *count = 0; - *dataVersionFilterList = nullptr; - return; - } - - DataVersionFilter * dataVersionFilterArray = new DataVersionFilter[dataVersionFilterSize]; - size_t i = 0; - for (MTRClusterPath * path in dataVersions) { - NSNumber * dataVersionNumber = dataVersions[path]; - dataVersionFilterArray[i++] = DataVersionFilter(static_cast(path.endpoint.unsignedShortValue), static_cast(path.cluster.unsignedLongValue), static_cast(dataVersionNumber.unsignedLongValue)); - } - - *dataVersionFilterList = dataVersionFilterArray; - *count = dataVersionFilterSize; -} - -- (void)_setupConnectivityMonitoring -{ -#if ENABLE_CONNECTIVITY_MONITORING - // Dispatch to own queue because we used to need to do that to get the compressedFabricID, but - // at this point that's not really needed anymore. - dispatch_async(self.queue, ^{ - // Get the required info before setting up the connectivity monitor - NSNumber * compressedFabricID = [self->_deviceController compressedFabricID]; - if (!compressedFabricID) { - MTR_LOG_ERROR("%@ could not get compressed fabricID", self); - return; - } - - // Now lock for _connectivityMonitor - std::lock_guard lock(self->_lock); - if (self->_connectivityMonitor) { - // already monitoring - return; - } - - self->_connectivityMonitor = [[MTRDeviceConnectivityMonitor alloc] initWithCompressedFabricID:compressedFabricID nodeID:self.nodeID]; - [self->_connectivityMonitor startMonitoringWithHandler:^{ - [self->_deviceController asyncDispatchToMatterQueue:^{ - [self _triggerResubscribeWithReason:@"device connectivity changed" nodeLikelyReachable:YES]; - } - errorHandler:nil]; - } queue:self.queue]; - }); -#endif -} - -- (void)_stopConnectivityMonitoring -{ - os_unfair_lock_assert_owner(&_lock); - - if (_connectivityMonitor) { - [_connectivityMonitor stopMonitoring]; - _connectivityMonitor = nil; - } -} - -- (void)_resetSubscriptionWithReasonString:(NSString *)reasonString -{ - os_unfair_lock_assert_owner(&self->_lock); - MTR_LOG_ERROR("%@ %@ - resetting subscription", self, reasonString); - - [_deviceController asyncDispatchToMatterQueue:^{ - MTR_LOG("%@ subscription reset disconnecting ReadClient and SubscriptionCallback", self); - - std::lock_guard lock(self->_lock); - self->_currentReadClient = nullptr; - if (self->_currentSubscriptionCallback) { - delete self->_currentSubscriptionCallback; - } - self->_currentSubscriptionCallback = nullptr; - - [self _doHandleSubscriptionError:nil]; - // Use nil reset delay so that this keeps existing backoff timing - [self _doHandleSubscriptionReset:nil]; - } - errorHandler:nil]; -} - #ifdef DEBUG - (void)unitTestResetSubscription { - std::lock_guard lock(self->_lock); - [self _resetSubscriptionWithReasonString:@"Unit test reset subscription"]; } #endif -// assume lock is held -- (void)_setupSubscriptionWithReason:(NSString *)reason -{ - os_unfair_lock_assert_owner(&self->_lock); - - if (![self _subscriptionsAllowed]) { - MTR_LOG("%@ _setupSubscription: Subscriptions not allowed. Do not set up subscription (reason: %@)", self, reason); - return; - } - -#ifdef DEBUG - __block NSNumber * delegateMin = nil; - Optional maxIntervalOverride; - [self _callFirstDelegateSynchronouslyWithBlock:^(id testDelegate) { - if ([testDelegate respondsToSelector:@selector(unitTestMaxIntervalOverrideForSubscription:)]) { - delegateMin = [testDelegate unitTestMaxIntervalOverrideForSubscription:self]; - } - }]; - if (delegateMin) { - maxIntervalOverride.Emplace(delegateMin.unsignedIntValue); - } -#endif - - // for now just subscribe once - if (!NeedToStartSubscriptionSetup(_internalDeviceState)) { - MTR_LOG("%@ setupSubscription: no need to subscribe due to internal state %lu (reason: %@)", self, static_cast(_internalDeviceState), reason); - return; - } - - [self _changeInternalState:MTRInternalDeviceStateSubscribing]; - - MTR_LOG("%@ setting up subscription with reason: %@", self, reason); - - __block bool markUnreachableAfterWait = true; -#ifdef DEBUG - [self _callFirstDelegateSynchronouslyWithBlock:^(id testDelegate) { - if ([testDelegate respondsToSelector:@selector(unitTestSuppressTimeBasedReachabilityChanges:)]) { - markUnreachableAfterWait = ![testDelegate unitTestSuppressTimeBasedReachabilityChanges:self]; - } - }]; -#endif - - if (markUnreachableAfterWait) { - // Set up a timer to mark as not reachable if it takes too long to set up a subscription - mtr_weakify(self); - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, static_cast(kSecondsToWaitBeforeMarkingUnreachableAfterSettingUpSubscription) * static_cast(NSEC_PER_SEC)), self.queue, ^{ - mtr_strongify(self); - if (self != nil) { - std::lock_guard lock(self->_lock); - [self _markDeviceAsUnreachableIfNeverSubscribed]; - } - }); - } - - // This marks begin of initial subscription to the device (before CASE is established). The end is only marked after successfully setting - // up the subscription since it is always retried as long as the MTRDevice is kept running. - MATTER_LOG_METRIC_BEGIN(kMetricMTRDeviceInitialSubscriptionSetup); - - // Call directlyGetSessionForNode because the subscription setup already goes through the subscription pool queue - [_deviceController - directlyGetSessionForNode:_nodeID.unsignedLongLongValue - completion:^(chip::Messaging::ExchangeManager * _Nullable exchangeManager, - const chip::Optional & session, NSError * _Nullable error, - NSNumber * _Nullable retryDelay) { - if (error != nil) { - MTR_LOG_ERROR("%@ getSessionForNode error %@", self, error); - dispatch_async(self.queue, ^{ - [self _handleSubscriptionError:error]; - [self _handleSubscriptionReset:retryDelay]; - }); - return; - } - - auto callback = std::make_unique( - ^(NSArray * value) { - MTR_LOG("%@ got attribute report %@", self, value); - dispatch_async(self.queue, ^{ - // OnAttributeData - [self _handleAttributeReport:value fromSubscription:YES]; -#ifdef DEBUG - self->_unitTestAttributesReportedSinceLastCheck += value.count; -#endif - }); - }, - ^(NSArray * value) { - MTR_LOG("%@ got event report %@", self, value); - dispatch_async(self.queue, ^{ - // OnEventReport - [self _handleEventReport:value]; - }); - }, - ^(NSError * error) { - MTR_LOG_ERROR("%@ got subscription error %@", self, error); - dispatch_async(self.queue, ^{ - // OnError - [self _handleSubscriptionError:error]; - }); - }, - ^(NSError * error, NSNumber * resubscriptionDelayMs) { - MTR_LOG_ERROR("%@ got resubscription error %@ delay %@", self, error, resubscriptionDelayMs); - dispatch_async(self.queue, ^{ - // OnResubscriptionNeeded - [self _handleResubscriptionNeededWithDelay:resubscriptionDelayMs]; - }); - }, - ^(void) { - MTR_LOG("%@ got subscription established", self); - std::lock_guard lock(self->_lock); - - // First synchronously change state - if (HadSubscriptionEstablishedOnce(self->_internalDeviceState)) { - [self _changeInternalState:MTRInternalDeviceStateLaterSubscriptionEstablished]; - } else { - MATTER_LOG_METRIC_END(kMetricMTRDeviceInitialSubscriptionSetup, CHIP_NO_ERROR); - [self _changeInternalState:MTRInternalDeviceStateInitialSubscriptionEstablished]; - } - - [self _changeState:MTRDeviceStateReachable]; - - // Then async work that shouldn't be performed on the matter queue - dispatch_async(self.queue, ^{ - // OnSubscriptionEstablished - [self _handleSubscriptionEstablished]; - }); - }, - ^(void) { - MTR_LOG("%@ got subscription done", self); - // Drop our pointer to the ReadClient immediately, since - // it's about to be destroyed and we don't want to be - // holding a dangling pointer. - std::lock_guard lock(self->_lock); - self->_currentReadClient = nullptr; - self->_currentSubscriptionCallback = nullptr; - - dispatch_async(self.queue, ^{ - // OnDone - [self _handleSubscriptionReset:nil]; - }); - }, - ^(void) { - MTR_LOG("%@ got unsolicited message from publisher", self); - dispatch_async(self.queue, ^{ - // OnUnsolicitedMessageFromPublisher - [self _handleUnsolicitedMessageFromPublisher]; - }); - }, - ^(void) { - MTR_LOG("%@ got report begin", self); - dispatch_async(self.queue, ^{ - [self _handleReportBegin]; - }); - }, - ^(void) { - MTR_LOG("%@ got report end", self); - dispatch_async(self.queue, ^{ - [self _handleReportEnd]; - }); - }); - - // Set up a cluster state cache. We just want this for the logic it has for - // tracking data versions and event numbers so we minimize the amount of data we - // request on resubscribes, so tell it not to store data. - auto clusterStateCache = std::make_unique(*callback.get(), - /* highestReceivedEventNumber = */ NullOptional, - /* cacheData = */ false); - auto readClient = std::make_unique(InteractionModelEngine::GetInstance(), exchangeManager, - clusterStateCache->GetBufferedCallback(), ReadClient::InteractionType::Subscribe); - - // Wildcard endpoint, cluster, attribute, event. - auto attributePath = std::make_unique(); - auto eventPath = std::make_unique(); - // We want to get event reports at the minInterval, not the maxInterval. - eventPath->mIsUrgentEvent = true; - ReadPrepareParams readParams(session.Value()); - - readParams.mMinIntervalFloorSeconds = 0; - // Select a max interval based on the device's claimed idle sleep interval. - auto idleSleepInterval = std::chrono::duration_cast( - session.Value()->GetRemoteMRPConfig().mIdleRetransTimeout); - - auto maxIntervalCeilingMin = System::Clock::Seconds32(MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MIN); - if (idleSleepInterval < maxIntervalCeilingMin) { - idleSleepInterval = maxIntervalCeilingMin; - } - - auto maxIntervalCeilingMax = System::Clock::Seconds32(MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MAX); - if (idleSleepInterval > maxIntervalCeilingMax) { - idleSleepInterval = maxIntervalCeilingMax; - } -#ifdef DEBUG - if (maxIntervalOverride.HasValue()) { - idleSleepInterval = maxIntervalOverride.Value(); - } -#endif - readParams.mMaxIntervalCeilingSeconds = static_cast(idleSleepInterval.count()); - - readParams.mpAttributePathParamsList = attributePath.get(); - readParams.mAttributePathParamsListSize = 1; - readParams.mpEventPathParamsList = eventPath.get(); - readParams.mEventPathParamsListSize = 1; - readParams.mKeepSubscriptions = true; - readParams.mIsFabricFiltered = false; - - // Subscribe with data version filter list from our cache. - size_t dataVersionFilterListSize = 0; - DataVersionFilter * dataVersionFilterList; - [self _createDataVersionFilterListFromDictionary:[self _getCachedDataVersions] dataVersionFilterList:&dataVersionFilterList count:&dataVersionFilterListSize]; - - readParams.mDataVersionFilterListSize = dataVersionFilterListSize; - readParams.mpDataVersionFilterList = dataVersionFilterList; - attributePath.release(); - eventPath.release(); - - // TODO: Change from local filter list generation to rehydrating ClusterStateCache to take advantage of existing filter list sorting algorithm - - // SendAutoResubscribeRequest cleans up the params, even on failure. - CHIP_ERROR err = readClient->SendAutoResubscribeRequest(std::move(readParams)); - if (err != CHIP_NO_ERROR) { - NSError * error = [MTRError errorForCHIPErrorCode:err logContext:self]; - MTR_LOG_ERROR("%@ SendAutoResubscribeRequest error %@", self, error); - dispatch_async(self.queue, ^{ - [self _handleSubscriptionError:error]; - [self _handleSubscriptionReset:nil]; - }); - - return; - } - - MTR_LOG("%@ Subscribe with data version list size %lu", self, static_cast(dataVersionFilterListSize)); - - // Callback and ClusterStateCache and ReadClient will be deleted - // when OnDone is called. - os_unfair_lock_lock(&self->_lock); - self->_currentReadClient = readClient.get(); - self->_currentSubscriptionCallback = callback.get(); - os_unfair_lock_unlock(&self->_lock); - callback->AdoptReadClient(std::move(readClient)); - callback->AdoptClusterStateCache(std::move(clusterStateCache)); - callback.release(); - }]; - - // Set up connectivity monitoring in case network becomes routable after any part of the subscription process goes into backoff retries. - [self _setupConnectivityMonitoring]; -} - #ifdef DEBUG - (NSUInteger)unitTestAttributesReportedSinceLastCheck { - NSUInteger attributesReportedSinceLastCheck = _unitTestAttributesReportedSinceLastCheck; - _unitTestAttributesReportedSinceLastCheck = 0; - return attributesReportedSinceLastCheck; + return 0; } - (NSUInteger)unitTestNonnullDelegateCount @@ -3627,13 +2613,6 @@ - (void)_pruneEndpointsIn:(MTRDeviceDataValueDictionary)previousPartsListValue } [self _removeClusters:clusterPathsToRemove doRemoveFromDataStore:NO]; [self.deviceController.controllerDataStore clearStoredClusterDataForNodeID:self.nodeID endpointID:endpoint]; - - [_deviceController asyncDispatchToMatterQueue:^{ - std::lock_guard lock(self->_lock); - if (self->_currentSubscriptionCallback) { - self->_currentSubscriptionCallback->ClearCachedAttributeState(static_cast(endpoint.unsignedLongLongValue)); - } - } errorHandler:nil]; } } @@ -3654,17 +2633,6 @@ - (void)_pruneClustersIn:(MTRDeviceDataValueDictionary)previousServerListValue } } [self _removeClusters:clusterPathsToRemove doRemoveFromDataStore:YES]; - - [_deviceController asyncDispatchToMatterQueue:^{ - std::lock_guard lock(self->_lock); - if (self->_currentSubscriptionCallback) { - for (NSNumber * cluster in toBeRemovedClusters) { - ConcreteClusterPath clusterPath(static_cast(endpointID.unsignedLongLongValue), - static_cast(cluster.unsignedLongLongValue)); - self->_currentSubscriptionCallback->ClearCachedAttributeState(clusterPath); - } - } - } errorHandler:nil]; } - (void)_pruneAttributesIn:(MTRDeviceDataValueDictionary)previousAttributeListValue @@ -3678,18 +2646,6 @@ - (void)_pruneAttributesIn:(MTRDeviceDataValueDictionary)previousAttributeListVa [toBeRemovedAttributes minusSet:attributesStillInCluster]; [self _removeAttributes:toBeRemovedAttributes fromCluster:clusterPath]; - - [_deviceController asyncDispatchToMatterQueue:^{ - std::lock_guard lock(self->_lock); - if (self->_currentSubscriptionCallback) { - for (NSNumber * attribute in toBeRemovedAttributes) { - ConcreteAttributePath attributePath(static_cast(clusterPath.endpoint.unsignedLongLongValue), - static_cast(clusterPath.cluster.unsignedLongLongValue), - static_cast(attribute.unsignedLongLongValue)); - self->_currentSubscriptionCallback->ClearCachedAttributeState(attributePath); - } - } - } errorHandler:nil]; } - (void)_pruneStoredDataForPath:(MTRAttributePath *)attributePath @@ -3924,25 +2880,6 @@ - (void)setPersistedDeviceData:(NSDictionary *)data } } -- (void)_storePersistedDeviceData -{ - os_unfair_lock_assert_owner(&self->_lock); - - auto datastore = _deviceController.controllerDataStore; - if (datastore == nil) { - // No way to store. - return; - } - - // For now the only data we have is our initial subscribe latency. - NSMutableDictionary * data = [NSMutableDictionary dictionary]; - if (_estimatedSubscriptionLatency != nil) { - data[sLastInitialSubscribeLatencyKey] = _estimatedSubscriptionLatency; - } - - [datastore storeDeviceData:[data copy] forNodeID:self.nodeID]; -} - #ifdef DEBUG - (MTRDeviceClusterData *)unitTestGetClusterDataForPath:(MTRClusterPath *)path { @@ -4370,20 +3307,11 @@ @implementation MTRDevice (MatterPrivateForInternalDragonsDoNotFeed) - (BOOL)_deviceHasActiveSubscription { - std::lock_guard lock(_lock); - - // TODO: This should always return YES for thread devices - return HaveSubscriptionEstablishedRightNow(_internalDeviceState); + return NO; } - (void)_deviceMayBeReachable { - MTR_LOG("%@ _deviceMayBeReachable called", self); - // TODO: This should only be allowed for thread devices - [_deviceController asyncDispatchToMatterQueue:^{ - [self _triggerResubscribeWithReason:@"SPI client indicated the device may now be reachable" - nodeLikelyReachable:YES]; - } errorHandler:nil]; } /* END DRAGONS */ @@ -4419,122 +3347,3 @@ - (void)invokeCommandWithEndpointID:(NSNumber *)endpointID } @end - -#pragma mark - SubscriptionCallback -namespace { -void SubscriptionCallback::OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus) -{ - if (mEventReports == nil) { - // Never got a OnReportBegin? Not much to do other than tear things down. - ReportError(CHIP_ERROR_INCORRECT_STATE); - return; - } - - MTREventPath * eventPath = [[MTREventPath alloc] initWithPath:aEventHeader.mPath]; - if (apStatus != nullptr) { - [mEventReports addObject:@ { MTREventPathKey : eventPath, MTRErrorKey : [MTRError errorForIMStatus:*apStatus] }]; - } else if (apData == nullptr) { - [mEventReports addObject:@ { - MTREventPathKey : eventPath, - MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT] - }]; - } else { - id value = MTRDecodeDataValueDictionaryFromCHIPTLV(apData); - if (value == nil) { - MTR_LOG_ERROR("Failed to decode event data for path %@", eventPath); - [mEventReports addObject:@ { - MTREventPathKey : eventPath, - MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_DECODE_FAILED], - }]; - } else { - [mEventReports addObject:[MTRBaseDevice eventReportForHeader:aEventHeader andData:value]]; - } - } - - QueueInterimReport(); -} - -void SubscriptionCallback::OnAttributeData( - const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const StatusIB & aStatus) -{ - if (aPath.IsListItemOperation()) { - ReportError(CHIP_ERROR_INCORRECT_STATE); - return; - } - - if (mAttributeReports == nil) { - // Never got a OnReportBegin? Not much to do other than tear things down. - ReportError(CHIP_ERROR_INCORRECT_STATE); - return; - } - - MTRAttributePath * attributePath = [[MTRAttributePath alloc] initWithPath:aPath]; - if (aStatus.mStatus != Status::Success) { - [mAttributeReports addObject:@ { MTRAttributePathKey : attributePath, MTRErrorKey : [MTRError errorForIMStatus:aStatus] }]; - } else if (apData == nullptr) { - [mAttributeReports addObject:@ { - MTRAttributePathKey : attributePath, - MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT] - }]; - } else { - NSNumber * dataVersionNumber = aPath.mDataVersion.HasValue() ? @(aPath.mDataVersion.Value()) : nil; - NSDictionary * value = MTRDecodeDataValueDictionaryFromCHIPTLV(apData, dataVersionNumber); - if (value == nil) { - MTR_LOG_ERROR("Failed to decode attribute data for path %@", attributePath); - [mAttributeReports addObject:@ { - MTRAttributePathKey : attributePath, - MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_DECODE_FAILED], - }]; - } else { - [mAttributeReports addObject:@ { MTRAttributePathKey : attributePath, MTRDataKey : value }]; - } - } - - QueueInterimReport(); -} - -uint32_t SubscriptionCallback::ComputeTimeTillNextSubscription() -{ - uint32_t maxWaitTimeInMsec = 0; - uint32_t waitTimeInMsec = 0; - uint32_t minWaitTimeInMsec = 0; - - if (mResubscriptionNumRetries <= CHIP_RESUBSCRIBE_MAX_FIBONACCI_STEP_INDEX) { - maxWaitTimeInMsec = GetFibonacciForIndex(mResubscriptionNumRetries) * CHIP_RESUBSCRIBE_WAIT_TIME_MULTIPLIER_MS; - } else { - maxWaitTimeInMsec = CHIP_RESUBSCRIBE_MAX_RETRY_WAIT_INTERVAL_MS; - } - - if (maxWaitTimeInMsec != 0) { - minWaitTimeInMsec = (CHIP_RESUBSCRIBE_MIN_WAIT_TIME_INTERVAL_PERCENT_PER_STEP * maxWaitTimeInMsec) / 100; - waitTimeInMsec = minWaitTimeInMsec + (Crypto::GetRandU32() % (maxWaitTimeInMsec - minWaitTimeInMsec)); - } - - return waitTimeInMsec; -} - -CHIP_ERROR SubscriptionCallback::OnResubscriptionNeeded(ReadClient * apReadClient, CHIP_ERROR aTerminationCause) -{ - // No need to check ReadClient internal state is Idle because ReadClient only calls OnResubscriptionNeeded after calling ClearActiveSubscriptionState(), which sets the state to Idle. - - // This part is copied from ReadClient's DefaultResubscribePolicy: - auto timeTillNextResubscriptionMs = ComputeTimeTillNextSubscription(); - ChipLogProgress(DataManagement, - "Will try to resubscribe to %02x:" ChipLogFormatX64 " at retry index %" PRIu32 " after %" PRIu32 - "ms due to error %" CHIP_ERROR_FORMAT, - apReadClient->GetFabricIndex(), ChipLogValueX64(apReadClient->GetPeerNodeId()), mResubscriptionNumRetries, timeTillNextResubscriptionMs, - aTerminationCause.Format()); - - // Schedule a maximum time resubscription, to be triggered with TriggerResubscribeIfScheduled after a separate timer. - // This way the aReestablishCASE value is saved, and the sanity checks in ScheduleResubscription are observed and returned. - ReturnErrorOnFailure(apReadClient->ScheduleResubscription(UINT32_MAX, NullOptional, aTerminationCause == CHIP_ERROR_TIMEOUT)); - - // Not as good a place to increment as when resubscription timer fires, but as is, this should be as good, because OnResubscriptionNeeded is only called from ReadClient's Close() while Idle, and nothing should cause this to happen - mResubscriptionNumRetries++; - - auto error = [MTRError errorForCHIPErrorCode:aTerminationCause]; - CallResubscriptionScheduledHandler(error, @(timeTillNextResubscriptionMs)); - - return CHIP_NO_ERROR; -} -} // anonymous namespace diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 322593312ccea4..11fd481b48b2fc 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -109,9 +109,6 @@ using namespace chip::Tracing::DarwinFramework; @implementation MTRDeviceController { - // queue used to serialize all work performed by the MTRDeviceController - dispatch_queue_t _chipWorkQueue; - chip::Controller::DeviceCommissioner * _cppCommissioner; chip::Credentials::PartialDACVerifier * _partialDACVerifier; chip::Credentials::DefaultDACVerifier * _defaultDACVerifier; diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h index 85d2c2e069ee2c..54d5cfd8d340fa 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDeviceController_Internal.h @@ -68,6 +68,10 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readwrite, nullable) NSMapTable * nodeIDToDeviceMap; @property (readonly, assign) os_unfair_lock_t deviceMapLock; +// queue used to serialize all work performed by the MTRDeviceController +// (moved here so subclasses can initialize differently) +@property (readwrite, retain) dispatch_queue_t chipWorkQueue; + - (instancetype)initForSubclasses; #pragma mark - MTRDeviceControllerFactory methods diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm b/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm index 157a38199f025e..7111aa4eb7f2bd 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm @@ -43,6 +43,41 @@ @implementation MTRDeviceController_XPC @synthesize uniqueIdentifier = _uniqueIdentifier; +- (NSXPCInterface *)_interfaceForServerProtocol +{ + NSXPCInterface * interface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)]; + + NSSet * allowedClasses = [NSSet setWithArray:@[ + [NSString class], [NSNumber class], [NSData class], [NSArray class], [NSDictionary class], [NSError class], [MTRCommandPath class], [MTRAttributePath class] + ]]; + + [interface setClasses:allowedClasses + forSelector:@selector(deviceController:nodeID:invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:completion:) + argumentIndex:0 + ofReply:YES]; + return interface; +} + +- (NSXPCInterface *)_interfaceForClientProtocol +{ + NSXPCInterface * interface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCClientProtocol)]; + NSSet * allowedClasses = [NSSet setWithArray:@[ + [NSString class], [NSNumber class], [NSData class], [NSArray class], [NSDictionary class], [NSError class], [MTRAttributePath class] + ]]; + [interface setClasses:allowedClasses + forSelector:@selector(device:receivedAttributeReport:) + argumentIndex:1 + ofReply:NO]; + allowedClasses = [NSSet setWithArray:@[ + [NSString class], [NSNumber class], [NSData class], [NSArray class], [NSDictionary class], [NSError class], [MTREventPath class] + ]]; + [interface setClasses:allowedClasses + forSelector:@selector(device:receivedEventReport:) + argumentIndex:1 + ofReply:NO]; + return interface; +} + - (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection * (^)(void) )connectionBlock { if (self = [super initForSubclasses]) { @@ -59,12 +94,14 @@ - (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection self.xpcConnection = connectionBlock(); self.uniqueIdentifier = UUID; + self.chipWorkQueue = dispatch_queue_create("MTRDeviceController_XPC_queue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL); + self.nodeIDToDeviceMap = [NSMapTable strongToWeakObjectsMapTable]; MTR_LOG("Set up XPC Connection: %@", self.xpcConnection); if (self.xpcConnection) { - self.xpcConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)]; + self.xpcConnection.remoteObjectInterface = [self _interfaceForServerProtocol]; - self.xpcConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCClientProtocol)]; + self.xpcConnection.exportedInterface = [self _interfaceForClientProtocol]; self.xpcConnection.exportedObject = self; self.xpcConnection.interruptionHandler = ^{ @@ -96,9 +133,9 @@ - (id)initWithUniqueIdentifier:(NSUUID *)UUID machServiceName:(NSString *)machSe MTR_LOG("Set up XPC Connection: %@", self.xpcConnection); if (self.xpcConnection) { - self.xpcConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)]; + self.xpcConnection.remoteObjectInterface = [self _interfaceForServerProtocol]; - self.xpcConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCClientProtocol)]; + self.xpcConnection.exportedInterface = [self _interfaceForClientProtocol]; self.xpcConnection.exportedObject = self; MTR_LOG("%s: resuming new XPC connection"); diff --git a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm index e22b0b8edff243..120d29aff122d4 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm @@ -58,8 +58,6 @@ // allow readwrite access to superclass properties @interface MTRDevice_Concrete () -@property (nonatomic, readwrite, copy) NSNumber * nodeID; -@property (nonatomic, readwrite, nullable) MTRDeviceController * deviceController; @property (nonatomic, readwrite) MTRAsyncWorkQueue * asyncWorkQueue; @property (nonatomic, readwrite) MTRDeviceState state; @property (nonatomic, readwrite, nullable) NSDate * estimatedStartTime; @@ -74,84 +72,6 @@ @interface MTRDevice_Concrete () // Disabling pending crashes #define ENABLE_CONNECTIVITY_MONITORING 0 -// Consider moving utility classes to their own file -#pragma mark - Utility Classes - -// container of MTRDevice delegate weak reference, its queue, and its interested paths for attribute reports -MTR_DIRECT_MEMBERS -@interface MTRDeviceDelegateInfo_ConcreteCopy : NSObject { -@private - void * _delegatePointerValue; - __weak id _delegate; - dispatch_queue_t _queue; - NSArray * _Nullable _interestedPathsForAttributes; - NSArray * _Nullable _interestedPathsForEvents; -} - -// Array of interested cluster paths, attribute paths, or endpointID, for attribute report filtering. -@property (readonly, nullable) NSArray * interestedPathsForAttributes; - -// Array of interested cluster paths, attribute paths, or endpointID, for event report filtering. -@property (readonly, nullable) NSArray * interestedPathsForEvents; - -// Expose delegate -@property (readonly) id delegate; - -// Pointer value for logging purpose only -@property (readonly) void * delegatePointerValue; - -- (instancetype)initWithDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents; - -// Returns YES if delegate and queue are both non-null, and the block is scheduled to run. -- (BOOL)callDelegateWithBlock:(void (^)(id))block; - -#ifdef DEBUG -// Only used for unit test purposes - normal delegate should not expect or handle being called back synchronously. -- (BOOL)callDelegateSynchronouslyWithBlock:(void (^)(id))block; -#endif -@end - -@implementation MTRDeviceDelegateInfo_ConcreteCopy -- (instancetype)initWithDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents -{ - if (self = [super init]) { - _delegate = delegate; - _delegatePointerValue = (__bridge void *) delegate; - _queue = queue; - _interestedPathsForAttributes = [interestedPathsForAttributes copy]; - _interestedPathsForEvents = [interestedPathsForEvents copy]; - } - return self; -} - -- (NSString *)description -{ - return [NSString stringWithFormat:@"", self, _delegatePointerValue, static_cast(_interestedPathsForAttributes.count), static_cast(_interestedPathsForEvents.count)]; -} - -- (BOOL)callDelegateWithBlock:(void (^)(id))block -{ - id strongDelegate = _delegate; - VerifyOrReturnValue(strongDelegate, NO); - dispatch_async(_queue, ^{ - block(strongDelegate); - }); - return YES; -} - -#ifdef DEBUG -- (BOOL)callDelegateSynchronouslyWithBlock:(void (^)(id))block -{ - id strongDelegate = _delegate; - VerifyOrReturnValue(strongDelegate, NO); - - block(strongDelegate); - - return YES; -} -#endif -@end - /* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */ @interface NSObject (MatterPrivateForInternalDragonsDoNotFeed) @@ -281,7 +201,6 @@ typedef NS_ENUM(NSUInteger, MTRDeviceWorkItemDuplicateTypeID) { #define MTRDEVICE_SUBSCRIPTION_LATENCY_NEW_VALUE_WEIGHT (1.0 / 3.0) @interface MTRDevice_Concrete () -@property (nonatomic, readonly) os_unfair_lock lock; // protects the caches and device state // protects against concurrent time updates by guarding timeUpdateScheduled flag which manages time updates scheduling, // and protects device calls to setUTCTime and setDSTOffset. This can't just be replaced with "lock", because the time // update code calls public APIs like readAttributeWithEndpointID:.. (which attempt to take "lock") while holding @@ -412,8 +331,6 @@ @implementation MTRDevice_Concrete { // System time change observer reference id _systemTimeChangeObserverToken; - NSMutableSet * _delegates; - // Protects mutable state used by our description getter. This is a separate lock from "lock" // so that we don't need to worry about getting our description while holding "lock" (e.g due to // logging self). This lock _must_ be held narrowly, with no other lock acquisitions allowed @@ -437,8 +354,6 @@ @implementation MTRDevice_Concrete { } // synthesize superclass property readwrite accessors -@synthesize nodeID = _nodeID; -@synthesize deviceController = _deviceController; @synthesize queue = _queue; @synthesize asyncWorkQueue = _asyncWorkQueue; @synthesize state = _state; @@ -450,13 +365,10 @@ @implementation MTRDevice_Concrete { - (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller { // `super` was NSObject, is now MTRDevice. MTRDevice hides its `init` - if (self = [super initForSubclasses]) { - _lock = OS_UNFAIR_LOCK_INIT; + if (self = [super initForSubclassesWithNodeID:nodeID controller:controller]) { _timeSyncLock = OS_UNFAIR_LOCK_INIT; _descriptionLock = OS_UNFAIR_LOCK_INIT; - _nodeID = [nodeID copy]; _fabricIndex = controller.fabricIndex; - _deviceController = controller; _queue = dispatch_queue_create("org.csa-iot.matter.framework.device.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL); _expectedValueCache = [NSMutableDictionary dictionary]; @@ -483,8 +395,6 @@ - (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceControlle }]; } - _delegates = [NSMutableSet set]; - MTR_LOG_DEBUG("%@ init with hex nodeID 0x%016llX", self, _nodeID.unsignedLongLongValue); } return self; @@ -551,7 +461,7 @@ - (NSString *)description } return [NSString - stringWithFormat:@"", self, _deviceController.compressedFabricID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, vid, pid, wifi, thread, InternalDeviceStateString(internalDeviceState), static_cast(lastSubscriptionAttemptWait), static_cast(_asyncWorkQueue.itemCount), mostRecentReportTime, reportAge, lastSubscriptionFailureTime, subscriptionFailureAge, _deviceController.uniqueIdentifier]; + stringWithFormat:@"", self, _deviceController.compressedFabricID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, vid, pid, wifi, thread, InternalDeviceStateString(internalDeviceState), static_cast(lastSubscriptionAttemptWait), static_cast(_asyncWorkQueue.itemCount), mostRecentReportTime, reportAge, lastSubscriptionFailureTime, subscriptionFailureAge, _deviceController.uniqueIdentifier]; } + (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller @@ -792,49 +702,9 @@ - (BOOL)_subscriptionsAllowed return ![_deviceController isKindOfClass:MTRDeviceControllerOverXPC.class]; } -- (void)setDelegate:(id)delegate queue:(dispatch_queue_t)queue -{ - MTR_LOG("%@ setDelegate %@", self, delegate); - [self _addDelegate:delegate queue:queue interestedPathsForAttributes:nil interestedPathsForEvents:nil]; -} - -- (void)addDelegate:(id)delegate queue:(dispatch_queue_t)queue -{ - MTR_LOG("%@ addDelegate %@", self, delegate); - [self _addDelegate:delegate queue:queue interestedPathsForAttributes:nil interestedPathsForEvents:nil]; -} - -- (void)addDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents +- (void)_delegateAdded { - MTR_LOG("%@ addDelegate %@ with interested attribute paths %@ event paths %@", self, delegate, interestedPathsForAttributes, interestedPathsForEvents); - [self _addDelegate:delegate queue:queue interestedPathsForAttributes:interestedPathsForAttributes interestedPathsForEvents:interestedPathsForEvents]; -} - -- (void)_addDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents -{ - std::lock_guard lock(_lock); - - // Replace delegate info with the same delegate object, and opportunistically remove defunct delegate references - NSMutableSet * delegatesToRemove = [NSMutableSet set]; - for (MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo in _delegates) { - id strongDelegate = delegateInfo.delegate; - if (!strongDelegate) { - [delegatesToRemove addObject:delegateInfo]; - MTR_LOG("%@ removing delegate info for nil delegate %p", self, delegateInfo.delegatePointerValue); - } else if (strongDelegate == delegate) { - [delegatesToRemove addObject:delegateInfo]; - MTR_LOG("%@ replacing delegate info for %p", self, delegate); - } - } - if (delegatesToRemove.count) { - NSUInteger oldDelegatesCount = _delegates.count; - [_delegates minusSet:delegatesToRemove]; - MTR_LOG("%@ addDelegate: removed %lu", self, static_cast(_delegates.count - oldDelegatesCount)); - } - - MTRDeviceDelegateInfo_ConcreteCopy * newDelegateInfo = [[MTRDeviceDelegateInfo_ConcreteCopy alloc] initWithDelegate:delegate queue:queue interestedPathsForAttributes:interestedPathsForAttributes interestedPathsForEvents:interestedPathsForEvents]; - [_delegates addObject:newDelegateInfo]; - MTR_LOG("%@ added delegate info %@", self, newDelegateInfo); + os_unfair_lock_assert_owner(&self->_lock); __block BOOL shouldSetUpSubscription = [self _subscriptionsAllowed]; @@ -866,27 +736,6 @@ - (void)_addDelegate:(id)delegate queue:(dispatch_queue_t)que } } -- (void)removeDelegate:(id)delegate -{ - MTR_LOG("%@ removeDelegate %@", self, delegate); - - std::lock_guard lock(_lock); - - NSMutableSet * delegatesToRemove = [NSMutableSet set]; - [self _iterateDelegatesWithBlock:^(MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo) { - id strongDelegate = delegateInfo.delegate; - if (strongDelegate == delegate) { - [delegatesToRemove addObject:delegateInfo]; - MTR_LOG("%@ removing delegate info %@ for %p", self, delegateInfo, delegate); - } - }]; - if (delegatesToRemove.count) { - NSUInteger oldDelegatesCount = _delegates.count; - [_delegates minusSet:delegatesToRemove]; - MTR_LOG("%@ removeDelegate: removed %lu", self, static_cast(_delegates.count - oldDelegatesCount)); - } -} - - (void)invalidate { MTR_LOG("%@ invalidate", self); @@ -901,8 +750,6 @@ - (void)invalidate _state = MTRDeviceStateUnknown; - [_delegates removeAllObjects]; - // Make sure we don't try to resubscribe if we have a pending resubscribe // attempt, since we now have no delegate. _reattemptingSubscription = NO; @@ -928,6 +775,8 @@ - (void)invalidate [self _stopConnectivityMonitoring]; os_unfair_lock_unlock(&self->_lock); + + [super invalidate]; } - (void)nodeMayBeAdvertisingOperational @@ -1052,79 +901,6 @@ - (void)_readThroughSkipped errorHandler:nil]; } -- (BOOL)_delegateExists -{ - os_unfair_lock_assert_owner(&self->_lock); - return [self _iterateDelegatesWithBlock:nil]; -} - -// Returns YES if any non-null delegates were found -- (BOOL)_iterateDelegatesWithBlock:(void(NS_NOESCAPE ^)(MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo)_Nullable)block -{ - os_unfair_lock_assert_owner(&self->_lock); - - if (!_delegates.count) { - MTR_LOG_DEBUG("%@ no delegates to iterate", self); - return NO; - } - - // Opportunistically remove defunct delegate references on every iteration - NSMutableSet * delegatesToRemove = nil; - for (MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo in _delegates) { - id strongDelegate = delegateInfo.delegate; - if (strongDelegate) { - if (block) { - @autoreleasepool { - block(delegateInfo); - } - } - (void) strongDelegate; // ensure it stays alive - } else { - if (!delegatesToRemove) { - delegatesToRemove = [NSMutableSet set]; - } - [delegatesToRemove addObject:delegateInfo]; - } - } - - if (delegatesToRemove.count) { - [_delegates minusSet:delegatesToRemove]; - MTR_LOG("%@ _iterateDelegatesWithBlock: removed %lu remaining %lu", self, static_cast(delegatesToRemove.count), (unsigned long) static_cast(_delegates.count)); - } - - return (_delegates.count > 0); -} - -- (BOOL)_callDelegatesWithBlock:(void (^)(id delegate))block -{ - os_unfair_lock_assert_owner(&self->_lock); - - __block NSUInteger delegatesCalled = 0; - [self _iterateDelegatesWithBlock:^(MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo) { - if ([delegateInfo callDelegateWithBlock:block]) { - delegatesCalled++; - } - }]; - - return (delegatesCalled > 0); -} - -#ifdef DEBUG -// Only used for unit test purposes - normal delegate should not expect or handle being called back synchronously -// Returns YES if a delegate is called -- (void)_callFirstDelegateSynchronouslyWithBlock:(void (^)(id delegate))block -{ - os_unfair_lock_assert_owner(&self->_lock); - - for (MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo in _delegates) { - if ([delegateInfo callDelegateSynchronouslyWithBlock:block]) { - MTR_LOG("%@ _callFirstDelegateSynchronouslyWithBlock: successfully called %@", self, delegateInfo); - return; - } - } -} -#endif - - (void)_callDelegateDeviceCachePrimed { os_unfair_lock_assert_owner(&self->_lock); @@ -1944,7 +1720,7 @@ - (void)_reportAttributes:(NSArray *> *)attributes { os_unfair_lock_assert_owner(&self->_lock); if (attributes.count) { - [self _iterateDelegatesWithBlock:^(MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo) { + [self _iterateDelegatesWithBlock:^(MTRDeviceDelegateInfo * delegateInfo) { // _iterateDelegatesWithBlock calls this with an autorelease pool, and so temporary filtered attributes reports don't bloat memory NSArray *> * filteredAttributes = [self _filteredAttributes:attributes forInterestedPaths:delegateInfo.interestedPathsForAttributes]; if (filteredAttributes.count) { @@ -2123,7 +1899,7 @@ - (void)_handleEventReport:(NSArray *> *)eventRepor } __block BOOL delegatesCalled = NO; - [self _iterateDelegatesWithBlock:^(MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo) { + [self _iterateDelegatesWithBlock:^(MTRDeviceDelegateInfo * delegateInfo) { // _iterateDelegatesWithBlock calls this with an autorelease pool, and so temporary filtered event reports don't bloat memory NSArray *> * filteredEvents = [self _filteredEvents:reportToReturn forInterestedPaths:delegateInfo.interestedPathsForEvents]; if (filteredEvents.count) { @@ -2658,20 +2434,6 @@ - (NSUInteger)unitTestAttributesReportedSinceLastCheck _unitTestAttributesReportedSinceLastCheck = 0; return attributesReportedSinceLastCheck; } - -- (NSUInteger)unitTestNonnullDelegateCount -{ - std::lock_guard lock(self->_lock); - - NSUInteger nonnullDelegateCount = 0; - for (MTRDeviceDelegateInfo_ConcreteCopy * delegateInfo in _delegates) { - if (delegateInfo.delegate) { - nonnullDelegateCount++; - } - } - - return nonnullDelegateCount; -} #endif #pragma mark Device Interactions diff --git a/src/darwin/Framework/CHIP/MTRDevice_Internal.h b/src/darwin/Framework/CHIP/MTRDevice_Internal.h index 4c1b51f51c0a48..b6a59ac9321d42 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDevice_Internal.h @@ -18,6 +18,7 @@ #import #import #import +#import #import "MTRAsyncWorkQueue.h" #import "MTRDefines_Internal.h" @@ -65,8 +66,63 @@ MTR_TESTABLE - (nullable instancetype)initWithDataVersion:(NSNumber * _Nullable)dataVersion attributes:(NSDictionary * _Nullable)attributes; @end -@interface MTRDevice () -- (instancetype)initForSubclasses; +// Consider moving utility classes to their own file +#pragma mark - Utility Classes + +/** + * container of MTRDevice delegate weak reference, its queue, and its interested + * paths for attribute reports. + */ +MTR_DIRECT_MEMBERS +@interface MTRDeviceDelegateInfo : NSObject { +@private + void * _delegatePointerValue; + __weak id _delegate; + dispatch_queue_t _queue; +} + +// Array of interested cluster paths, attribute paths, or endpointID, for attribute report filtering. +@property (readonly, nullable) NSArray * interestedPathsForAttributes; + +// Array of interested cluster paths, attribute paths, or endpointID, for event report filtering. +@property (readonly, nullable) NSArray * interestedPathsForEvents; + +// Expose delegate +@property (readonly) id delegate; + +// Pointer value for logging purpose only +@property (readonly) void * delegatePointerValue; + +- (instancetype)initWithDelegate:(id)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents; + +// Returns YES if delegate and queue are both non-null, and the block is scheduled to run. +- (BOOL)callDelegateWithBlock:(void (^)(id))block; + +#ifdef DEBUG +// Only used for unit test purposes - normal delegate should not expect or handle being called back synchronously. +- (BOOL)callDelegateSynchronouslyWithBlock:(void (^)(id))block; +#endif +@end + +#pragma mark - MTRDevice internal extensions + +@interface MTRDevice () { + // Ivars needed to implement shared MTRDevice functionality. +@protected + // Lock that protects overall device state, including delegate storage. + os_unfair_lock _lock; + NSMutableSet * _delegates; + + // Our node ID, with the ivar declared explicitly so it's accessible to + // subclasses. + NSNumber * _nodeID; + + // Our controller. Declared nullable because our property is, though in + // practice it does not look like we ever set it to nil. + MTRDeviceController * _Nullable _deviceController; +} + +- (instancetype)initForSubclassesWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller; - (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller; // Called from MTRClusters for writes and commands @@ -83,6 +139,9 @@ MTR_TESTABLE - (BOOL)_callDelegatesWithBlock:(void (^)(id delegate))block; +// Called by MTRDevice_XPC to forward delegate callbacks +- (BOOL)_lockAndCallDelegatesWithBlock:(void (^)(id delegate))block; + /** * Like the public invokeCommandWithEndpointID but: * @@ -123,6 +182,19 @@ MTR_TESTABLE // Returns whether this MTRDevice uses Thread for communication - (BOOL)deviceUsesThread; +#pragma mark - MTRDevice functionality to deal with delegates. + +// Returns YES if any non-null delegates were found +- (BOOL)_iterateDelegatesWithBlock:(void(NS_NOESCAPE ^ _Nullable)(MTRDeviceDelegateInfo * delegateInfo))block; + +- (BOOL)_delegateExists; + +#ifdef DEBUG +// Only used for unit test purposes - normal delegate should not expect or handle being called back synchronously +// Returns YES if a delegate is called +- (void)_callFirstDelegateSynchronouslyWithBlock:(void (^)(id delegate))block; +#endif + @end #pragma mark - Constants diff --git a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm index 69eba5bc6f5ea4..03f318d83517d7 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm @@ -82,13 +82,34 @@ @implementation MTRDevice_XPC +- (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller +{ + // TODO: Verify that this is a valid MTRDeviceController_XPC? + + if (self = [super initForSubclassesWithNodeID:nodeID controller:controller]) { + // Nothing else to do, all set. + } + + return self; +} + +- (NSString *)description +{ + // TODO: Figure out whether, and if so how, to log: VID, PID, WiFi, Thread, + // internalDeviceState (do we even have such a thing here?), last + // subscription attempt wait (does that apply to us?) queued work (do we + // have any?), last report, last subscription failure (does that apply to us?). + return [NSString + stringWithFormat:@"", self, _deviceController.compressedFabricID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, _nodeID.unsignedLongLongValue, _deviceController.uniqueIdentifier]; +} + #pragma mark - Client Callbacks (MTRDeviceDelegate) // required methods for MTRDeviceDelegates - (oneway void)device:(NSNumber *)nodeID stateChanged:(MTRDeviceState)state { MTR_LOG("%s", __PRETTY_FUNCTION__); - [self _callDelegatesWithBlock:^(id delegate) { + [self _lockAndCallDelegatesWithBlock:^(id delegate) { [delegate device:self stateChanged:state]; }]; } @@ -96,7 +117,7 @@ - (oneway void)device:(NSNumber *)nodeID stateChanged:(MTRDeviceState)state - (oneway void)device:(NSNumber *)nodeID receivedAttributeReport:(NSArray *> *)attributeReport { MTR_LOG("%s", __PRETTY_FUNCTION__); - [self _callDelegatesWithBlock:^(id delegate) { + [self _lockAndCallDelegatesWithBlock:^(id delegate) { [delegate device:self receivedAttributeReport:attributeReport]; }]; } @@ -104,7 +125,7 @@ - (oneway void)device:(NSNumber *)nodeID receivedAttributeReport:(NSArray *> *)eventReport { MTR_LOG("%s", __PRETTY_FUNCTION__); - [self _callDelegatesWithBlock:^(id delegate) { + [self _lockAndCallDelegatesWithBlock:^(id delegate) { [delegate device:self receivedEventReport:eventReport]; }]; } @@ -113,7 +134,7 @@ - (oneway void)device:(NSNumber *)nodeID receivedEventReport:(NSArray delegate) { + [self _lockAndCallDelegatesWithBlock:^(id delegate) { if ([delegate respondsToSelector:@selector(deviceBecameActive:)]) { [delegate deviceBecameActive:self]; } @@ -122,7 +143,7 @@ - (oneway void)deviceBecameActive:(NSNumber *)nodeID - (oneway void)deviceCachePrimed:(NSNumber *)nodeID { - [self _callDelegatesWithBlock:^(id delegate) { + [self _lockAndCallDelegatesWithBlock:^(id delegate) { if ([delegate respondsToSelector:@selector(deviceCachePrimed:)]) { [delegate deviceCachePrimed:self]; } @@ -131,7 +152,7 @@ - (oneway void)deviceCachePrimed:(NSNumber *)nodeID - (oneway void)deviceConfigurationChanged:(NSNumber *)nodeID { - [self _callDelegatesWithBlock:^(id delegate) { + [self _lockAndCallDelegatesWithBlock:^(id delegate) { if ([delegate respondsToSelector:@selector(deviceConfigurationChanged:)]) { [delegate deviceConfigurationChanged:self]; } diff --git a/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCClientProtocol.h b/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCClientProtocol.h index a571ebc07a9257..3e276eb25f760d 100644 --- a/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCClientProtocol.h +++ b/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCClientProtocol.h @@ -1,6 +1,5 @@ -// /** - * Copyright (c) 2023 Project CHIP Authors + * 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. @@ -15,10 +14,12 @@ * limitations under the License. */ +#import #import // for MTRDeviceState NS_ASSUME_NONNULL_BEGIN +MTR_NEWLY_AVAILABLE @protocol MTRXPCClientProtocol_MTRDevice - (oneway void)device:(NSNumber *)nodeID stateChanged:(MTRDeviceState)state; - (oneway void)device:(NSNumber *)nodeID receivedAttributeReport:(NSArray *> *)attributeReport; @@ -28,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN - (oneway void)deviceConfigurationChanged:(NSNumber *)nodeID; @end +MTR_NEWLY_AVAILABLE @protocol MTRXPCClientProtocol_MTRDeviceController // Not Supported via XPC //- (oneway void)controller:(NSUUID *)controller statusUpdate:(MTRCommissioningStatus)status; @@ -36,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN //- (oneway void)controller:(NSUUID *)controller readCommissioningInfo:(MTRProductIdentity *)info; @end +MTR_NEWLY_AVAILABLE @protocol MTRXPCClientProtocol @end diff --git a/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h b/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h index 5d619453b5fd93..1eebb0396570ac 100644 --- a/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h +++ b/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h @@ -1,6 +1,5 @@ -// /** - * Copyright (c) 2023 Project CHIP Authors + * 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. @@ -15,8 +14,11 @@ * limitations under the License. */ +#import + NS_ASSUME_NONNULL_BEGIN +MTR_NEWLY_AVAILABLE @protocol MTRXPCServerProtocol_MTRDevice - (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID getStateWithReply:(void (^)(MTRDeviceState state))reply; @@ -45,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN // - (oneway void)downloadLogOfType:(MTRDiagnosticLogType)type nodeID:(NSNumber *)nodeID timeout:(NSTimeInterval)timeout completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion; @end +MTR_NEWLY_AVAILABLE @protocol MTRXPCServerProtocol_MTRDeviceController - (oneway void)deviceController:(NSUUID *)controller getIsRunningWithReply:(void (^)(BOOL response))reply; @@ -69,6 +72,7 @@ NS_ASSUME_NONNULL_BEGIN @end +MTR_NEWLY_AVAILABLE @protocol MTRXPCServerProtocol - (oneway void)deviceController:(NSUUID *)controller checkInWithContext:(NSDictionary *)context; @end diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 507e19eae032d9..2272d5256d934e 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -3237,9 +3237,15 @@ - FanModeSequenceType - FanModeType ColorControl: - - ColorLoopAction - - ColorLoopDirection - - ColorMode + # ColorLoopActionEnum, ColorLoopDirectionEnum and ColorModeEnum + # were originally named ColorLoopAction, ColorLoopDirection, and + # ColorMode, but we generate the same API for the names + # with/without "Enum" at the end and the cluster name + # present/absent at the beginning, so the names can just change + # here. + - ColorLoopActionEnum + - ColorLoopDirectionEnum + - ColorModeEnum - HueDirection - HueMoveMode - HueStepMode @@ -3980,14 +3986,20 @@ - Auto - Smart ColorControl: - ColorLoopAction: + # ColorLoopActionEnum, ColorLoopDirectionEnum and ColorModeEnum + # were originally named ColorLoopAction, ColorLoopDirection, and + # ColorMode, but we generate the same API for the names + # with/without "Enum" at the end and the cluster name + # present/absent at the beginning, so the names can just change + # here. + ColorLoopActionEnum: - Deactivate - ActivateFromColorLoopStartEnhancedHue - ActivateFromEnhancedCurrentHue - ColorLoopDirection: + ColorLoopDirectionEnum: - DecrementHue - IncrementHue - ColorMode: + ColorModeEnum: - CurrentHueAndCurrentSaturation - CurrentXAndCurrentY - ColorTemperature @@ -9682,6 +9694,64 @@ - release: "Future" versions: "future" + introduced: + enums: + ColorControl: + - DirectionEnum + - DriftCompensationEnum + - EnhancedColorModeEnum + - MoveModeEnum + - StepModeEnum + enum values: + ColorControl: + ColorLoopDirectionEnum: + - Decrement + - Increment + ColorModeEnum: + - ColorTemperatureMireds + DirectionEnum: + - Shortest + - Longest + - Up + - Down + DriftCompensationEnum: + - None + - OtherOrUnknown + - TemperatureMonitoring + - OpticalLuminanceMonitoringAndFeedback + - OpticalColorMonitoringAndFeedback + EnhancedColorModeEnum: + - CurrentHueAndCurrentSaturation + - CurrentXAndCurrentY + - ColorTemperatureMireds + - EnhancedCurrentHueAndCurrentSaturation + MoveModeEnum: + - Stop + - Up + - Down + StepModeEnum: + - Up + - Down + bitmaps: + ColorControl: + - ColorCapabilitiesBitmap + - OptionsBitmap + - UpdateFlagsBitmap + bitmap values: + ColorControl: + ColorCapabilitiesBitmap: + - HueSaturation + - EnhancedHue + - ColorLoop + - XY + - ColorTemperature + OptionsBitmap: + - ExecuteIfOff + UpdateFlagsBitmap: + - UpdateAction + - UpdateDirection + - UpdateTime + - UpdateStartHue provisional: clusters: # Targeting 1.4 @@ -9694,6 +9764,13 @@ - WaterHeaterMode - WiFiNetworkManagement attributes: + AccessControl: + # Targeting 1.4 + - CommissioningARL + - ARL + BridgedDeviceBasicInformation: + # Targeting 1.4 + - ProductID GeneralCommissioning: # Targeting 1.4 - TCAcceptedVersion @@ -9712,6 +9789,10 @@ - NullableGlobalEnum - NullableGlobalStruct commands: + AccessControl: + # Targeting 1.4 + - ReviewFabricRestrictions + - ReviewFabricRestrictionsResponse BridgedDeviceBasicInformation: # Targeting 1.4 - KeepActive @@ -9719,6 +9800,10 @@ # Targeting 1.4 - SetTCAcknowledgements - SetTCAcknowledgementsResponse + Thermostat: + # Targeting 1.4 + - AtomicRequest + - AtomicResponse UnitTesting: # Ideally none of UnitTesting would be exposed as public API, but # for now just start doing that for new additions to it. @@ -9727,9 +9812,17 @@ - StringEchoRequest - StringEchoResponse structs: + AccessControl: + # Targeting 1.4 + - AccessRestrictionEntryStruct + - AccessRestrictionStruct + - CommissioningAccessRestrictionEntryStruct Globals: # Test-only value - TestGlobalStruct + # Targeting 1.4 + - AtomicAttributeStatusStruct + - LocationDescriptorStruct OccupancySensing: # Targeting 1.4 - HoldTimeLimitsStruct @@ -9742,21 +9835,44 @@ NestedStruct: - d events: + AccessControl: + # Targeting 1.4 + - AccessRestrictionEntryChanged + - FabricRestrictionReviewUpdate BridgedDeviceBasicInformation: # Targeting 1.4 - ActiveChanged enums: + AccessControl: + # Targeting 1.4 + - AccessRestrictionTypeEnum Globals: # Test-only value - TestGlobalEnum + # Targeting 1.4 + - AreaTypeTag + - AtomicRequestTypeEnum + - FloorSurfaceTag + - LandmarkTag + - PositionTag + - RelativePositionTag enum values: + ApplicationLauncher: + StatusEnum: + # Targeting 1.4 + - Downloading + - Installing + - PendingUserApproval GeneralCommissioning: - # Targeting 1.4 CommissioningErrorEnum: + # Targeting 1.4 - RequiredTCNotAccepted - TCAcknowledgementsNotReceived - TCMinVersionNotMet bitmaps: + AccessControl: + # Targeting 1.4 + - Feature BridgedDeviceBasicInformation: # Targeting 1.4 - Feature @@ -9766,8 +9882,72 @@ OccupancySensing: # Targeting 1.4 - Feature + Thermostat: + # Targeting 1.4 + - OccupancyBitmap bitmap values: Switch: Feature: # Targeting 1.4 - ActionSwitch + renames: + enums: + ColorControl: + DirectionEnum: HueDirection + MoveModeEnum: HueMoveMode + StepModeEnum: HueStepMode + enum values: + ColorControl: + ColorLoopDirectionEnum: + Decrement: DecrementHue + Increment: IncrementHue + ColorModeEnum: + ColorTemperatureMireds: ColorTemperature + HueDirection: + Shortest: ShortestDistance + Longest: LongestDistance + bitmaps: + ColorControl: + ColorCapabilitiesBitmap: ColorCapabilities + UpdateFlagsBitmap: ColorLoopUpdateFlags + bitmap values: + ColorControl: + ColorCapabilities: + HueSaturation: HueSaturationSupported + EnhancedHue: EnhancedHueSupported + ColorLoop: ColorLoopSupported + XY: XYAttributesSupported + ColorTemperature: ColorTemperatureSupported + deprecated: + enums: + ColorControl: + - HueDirection + - HueMoveMode + - HueStepMode + enum values: + ColorControl: + ColorLoopDirectionEnum: + - DecrementHue + - IncrementHue + ColorModeEnum: + - ColorTemperature + bitmaps: + ColorControl: + - ColorCapabilities + - ColorLoopUpdateFlags + removed: + enum values: + ColorControl: + # Don't expose the new value names on the old enum names + HueDirection: + - Shortest + - Longest + bitmap values: + ColorControl: + # Don't expose the new field names on the old bitmap names + ColorCapabilities: + - HueSaturation + - EnhancedHue + - ColorLoop + - XY + - ColorTemperature diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index f899dba1fafe44..472a630d93df68 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -12882,7 +12882,7 @@ static id _Nullable DecodeAttributeValueForColorControlCluster(AttributeId aAttr return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; return value; } case Attributes::CompensationText::Id: { @@ -12920,7 +12920,7 @@ static id _Nullable DecodeAttributeValueForColorControlCluster(AttributeId aAttr return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; return value; } case Attributes::Options::Id: { @@ -12931,7 +12931,7 @@ static id _Nullable DecodeAttributeValueForColorControlCluster(AttributeId aAttr return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + value = [NSNumber numberWithUnsignedChar:cppValue.Raw()]; return value; } case Attributes::NumberOfPrimaries::Id: { @@ -13323,7 +13323,7 @@ static id _Nullable DecodeAttributeValueForColorControlCluster(AttributeId aAttr return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; return value; } case Attributes::ColorLoopActive::Id: { @@ -13389,7 +13389,7 @@ static id _Nullable DecodeAttributeValueForColorControlCluster(AttributeId aAttr return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedShort:cppValue]; + value = [NSNumber numberWithUnsignedShort:cppValue.Raw()]; return value; } case Attributes::ColorTempPhysicalMinMireds::Id: { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index fab6862dd96a67..c00233470f81d6 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -20209,59 +20209,123 @@ typedef NS_ENUM(uint8_t, MTRColorControlColorLoopAction) { } MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); typedef NS_ENUM(uint8_t, MTRColorControlColorLoopDirection) { - MTRColorControlColorLoopDirectionDecrementHue MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, - MTRColorControlColorLoopDirectionIncrementHue MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, + MTRColorControlColorLoopDirectionDecrement MTR_NEWLY_AVAILABLE = 0x00, + MTRColorControlColorLoopDirectionDecrementHue MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorLoopDirectionDecrement") + = 0x00, + MTRColorControlColorLoopDirectionIncrement MTR_NEWLY_AVAILABLE = 0x01, + MTRColorControlColorLoopDirectionIncrementHue MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorLoopDirectionIncrement") + = 0x01, } MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); typedef NS_ENUM(uint8_t, MTRColorControlColorMode) { MTRColorControlColorModeCurrentHueAndCurrentSaturation MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, MTRColorControlColorModeCurrentXAndCurrentY MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, - MTRColorControlColorModeColorTemperature MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x02, + MTRColorControlColorModeColorTemperatureMireds MTR_NEWLY_AVAILABLE = 0x02, + MTRColorControlColorModeColorTemperature MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorModeColorTemperatureMireds") + = 0x02, } MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_ENUM(uint8_t, MTRColorControlDirection) { + MTRColorControlDirectionShortest MTR_NEWLY_AVAILABLE = 0x00, + MTRColorControlDirectionLongest MTR_NEWLY_AVAILABLE = 0x01, + MTRColorControlDirectionUp MTR_NEWLY_AVAILABLE = 0x02, + MTRColorControlDirectionDown MTR_NEWLY_AVAILABLE = 0x03, +} MTR_NEWLY_AVAILABLE; + typedef NS_ENUM(uint8_t, MTRColorControlHueDirection) { - MTRColorControlHueDirectionShortestDistance MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, - MTRColorControlHueDirectionLongestDistance MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, - MTRColorControlHueDirectionUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x02, - MTRColorControlHueDirectionDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x03, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); + MTRColorControlHueDirectionShortestDistance MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlDirectionShortest") + = 0x00, + MTRColorControlHueDirectionLongestDistance MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlDirectionLongest") + = 0x01, + MTRColorControlHueDirectionUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlDirectionUp") + = 0x02, + MTRColorControlHueDirectionDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlDirectionDown") + = 0x03, +} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlDirection"); + +typedef NS_ENUM(uint8_t, MTRColorControlDriftCompensation) { + MTRColorControlDriftCompensationNone MTR_NEWLY_AVAILABLE = 0x00, + MTRColorControlDriftCompensationOtherOrUnknown MTR_NEWLY_AVAILABLE = 0x01, + MTRColorControlDriftCompensationTemperatureMonitoring MTR_NEWLY_AVAILABLE = 0x02, + MTRColorControlDriftCompensationOpticalLuminanceMonitoringAndFeedback MTR_NEWLY_AVAILABLE = 0x03, + MTRColorControlDriftCompensationOpticalColorMonitoringAndFeedback MTR_NEWLY_AVAILABLE = 0x04, +} MTR_NEWLY_AVAILABLE; + +typedef NS_ENUM(uint8_t, MTRColorControlEnhancedColorMode) { + MTRColorControlEnhancedColorModeCurrentHueAndCurrentSaturation MTR_NEWLY_AVAILABLE = 0x00, + MTRColorControlEnhancedColorModeCurrentXAndCurrentY MTR_NEWLY_AVAILABLE = 0x01, + MTRColorControlEnhancedColorModeColorTemperatureMireds MTR_NEWLY_AVAILABLE = 0x02, + MTRColorControlEnhancedColorModeEnhancedCurrentHueAndCurrentSaturation MTR_NEWLY_AVAILABLE = 0x03, +} MTR_NEWLY_AVAILABLE; + +typedef NS_ENUM(uint8_t, MTRColorControlMoveMode) { + MTRColorControlMoveModeStop MTR_NEWLY_AVAILABLE = 0x00, + MTRColorControlMoveModeUp MTR_NEWLY_AVAILABLE = 0x01, + MTRColorControlMoveModeDown MTR_NEWLY_AVAILABLE = 0x03, +} MTR_NEWLY_AVAILABLE; typedef NS_ENUM(uint8_t, MTRColorControlHueMoveMode) { - MTRColorControlHueMoveModeStop MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, - MTRColorControlHueMoveModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, - MTRColorControlHueMoveModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x03, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); + MTRColorControlHueMoveModeStop MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeStop") + = 0x00, + MTRColorControlHueMoveModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeUp") + = 0x01, + MTRColorControlHueMoveModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeDown") + = 0x03, +} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveMode"); + +typedef NS_ENUM(uint8_t, MTRColorControlStepMode) { + MTRColorControlStepModeUp MTR_NEWLY_AVAILABLE = 0x01, + MTRColorControlStepModeDown MTR_NEWLY_AVAILABLE = 0x03, +} MTR_NEWLY_AVAILABLE; typedef NS_ENUM(uint8_t, MTRColorControlHueStepMode) { - MTRColorControlHueStepModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, - MTRColorControlHueStepModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x03, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); - -typedef NS_ENUM(uint8_t, MTRColorControlSaturationMoveMode) { - MTRColorControlSaturationMoveModeStop MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, - MTRColorControlSaturationMoveModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, - MTRColorControlSaturationMoveModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x03, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); - -typedef NS_ENUM(uint8_t, MTRColorControlSaturationStepMode) { - MTRColorControlSaturationStepModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, - MTRColorControlSaturationStepModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x03, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); + MTRColorControlHueStepModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepModeUp") + = 0x01, + MTRColorControlHueStepModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepModeDown") + = 0x03, +} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepMode"); + +typedef NS_OPTIONS(uint16_t, MTRColorControlColorCapabilitiesBitmap) { + MTRColorControlColorCapabilitiesBitmapHueSaturation MTR_NEWLY_AVAILABLE = 0x1, + MTRColorControlColorCapabilitiesBitmapEnhancedHue MTR_NEWLY_AVAILABLE = 0x2, + MTRColorControlColorCapabilitiesBitmapColorLoop MTR_NEWLY_AVAILABLE = 0x4, + MTRColorControlColorCapabilitiesBitmapXY MTR_NEWLY_AVAILABLE = 0x8, + MTRColorControlColorCapabilitiesBitmapColorTemperature MTR_NEWLY_AVAILABLE = 0x10, +} MTR_NEWLY_AVAILABLE; typedef NS_OPTIONS(uint16_t, MTRColorControlColorCapabilities) { - MTRColorControlColorCapabilitiesHueSaturationSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x1, - MTRColorControlColorCapabilitiesEnhancedHueSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x2, - MTRColorControlColorCapabilitiesColorLoopSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x4, - MTRColorControlColorCapabilitiesXYAttributesSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x8, - MTRColorControlColorCapabilitiesColorTemperatureSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); - -typedef NS_OPTIONS(uint8_t, MTRColorControlColorLoopUpdateFlags) { - MTRColorControlColorLoopUpdateFlagsUpdateAction MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x1, - MTRColorControlColorLoopUpdateFlagsUpdateDirection MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x2, - MTRColorControlColorLoopUpdateFlagsUpdateTime MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x4, - MTRColorControlColorLoopUpdateFlagsUpdateStartHue MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x8, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); + MTRColorControlColorCapabilitiesHueSaturationSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorCapabilitiesBitmapHueSaturation") + = 0x1, + MTRColorControlColorCapabilitiesEnhancedHueSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorCapabilitiesBitmapEnhancedHue") + = 0x2, + MTRColorControlColorCapabilitiesColorLoopSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorCapabilitiesBitmapColorLoop") + = 0x4, + MTRColorControlColorCapabilitiesXYAttributesSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorCapabilitiesBitmapXY") + = 0x8, + MTRColorControlColorCapabilitiesColorTemperatureSupported MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorCapabilitiesBitmapColorTemperature") + = 0x10, +} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlColorCapabilitiesBitmap"); typedef NS_OPTIONS(uint32_t, MTRColorControlFeature) { MTRColorControlFeatureHueAndSaturation MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x1, @@ -20271,6 +20335,33 @@ typedef NS_OPTIONS(uint32_t, MTRColorControlFeature) { MTRColorControlFeatureColorTemperature MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, } MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_OPTIONS(uint8_t, MTRColorControlOptionsBitmap) { + MTRColorControlOptionsBitmapExecuteIfOff MTR_NEWLY_AVAILABLE = 0x1, +} MTR_NEWLY_AVAILABLE; + +typedef NS_OPTIONS(uint8_t, MTRColorControlUpdateFlagsBitmap) { + MTRColorControlUpdateFlagsBitmapUpdateAction MTR_NEWLY_AVAILABLE = 0x1, + MTRColorControlUpdateFlagsBitmapUpdateDirection MTR_NEWLY_AVAILABLE = 0x2, + MTRColorControlUpdateFlagsBitmapUpdateTime MTR_NEWLY_AVAILABLE = 0x4, + MTRColorControlUpdateFlagsBitmapUpdateStartHue MTR_NEWLY_AVAILABLE = 0x8, +} MTR_NEWLY_AVAILABLE; + +typedef NS_OPTIONS(uint8_t, MTRColorControlColorLoopUpdateFlags) { + MTRColorControlColorLoopUpdateFlagsUpdateAction MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlUpdateFlagsBitmapUpdateAction") + = 0x1, + MTRColorControlColorLoopUpdateFlagsUpdateDirection MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlUpdateFlagsBitmapUpdateDirection") + = 0x2, + MTRColorControlColorLoopUpdateFlagsUpdateTime MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlUpdateFlagsBitmapUpdateTime") + = 0x4, + MTRColorControlColorLoopUpdateFlagsUpdateStartHue MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlUpdateFlagsBitmapUpdateStartHue") + = 0x8, +} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRColorControlUpdateFlagsBitmap"); + typedef NS_OPTIONS(uint8_t, MTRBallastConfigurationBallastStatusBitmap) { MTRBallastConfigurationBallastStatusBitmapBallastNonOperational MTR_PROVISIONALLY_AVAILABLE = 0x1, MTRBallastConfigurationBallastStatusBitmapLampFailure MTR_PROVISIONALLY_AVAILABLE = 0x2, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 756425bba1b764..2c81423cfbb46a 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -76739,7 +76739,7 @@ - (void)writeAttributeOptionsWithValue:(NSNumber * _Nonnull)value params:(MTRWri ListFreer listFreer; using TypeInfo = ColorControl::Attributes::Options::TypeInfo; TypeInfo::Type cppValue; - cppValue = value.unsignedCharValue; + cppValue = static_cast>(value.unsignedCharValue); chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 5c869616268ecc..a5934b16975260 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -7929,7 +7929,7 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTRThermostatClusterSetActivePresetRequestParams : NSObject -@property (nonatomic, copy) NSData * _Nonnull presetHandle MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSData * _Nullable presetHandle MTR_PROVISIONALLY_AVAILABLE; /** * Controls whether the command is a timed command (using Timed Invoke). * diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 976d5a0ef241be..5ae975508e9b75 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -22697,7 +22697,7 @@ - (instancetype)init { if (self = [super init]) { - _presetHandle = [NSData data]; + _presetHandle = nil; _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -22730,7 +22730,12 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader chip::app::Clusters::Thermostat::Commands::SetActivePresetRequest::Type encodableStruct; ListFreer listFreer; { - encodableStruct.presetHandle = AsByteSpan(self.presetHandle); + if (self.presetHandle == nil) { + encodableStruct.presetHandle.SetNull(); + } else { + auto & nonNullValue_0 = encodableStruct.presetHandle.SetNonNull(); + nonNullValue_0 = AsByteSpan(self.presetHandle); + } } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23153,10 +23158,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23250,10 +23255,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.rate = self.rate.unsignedCharValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23353,10 +23358,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedCharValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23450,10 +23455,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23547,10 +23552,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.rate = self.rate.unsignedCharValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23650,10 +23655,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedCharValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23753,10 +23758,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23856,10 +23861,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -23953,10 +23958,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.rateY = self.rateY.shortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24056,10 +24061,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24153,10 +24158,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24268,10 +24273,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24365,10 +24370,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.rate = self.rate.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24468,10 +24473,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24571,10 +24576,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.transitionTime = self.transitionTime.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24686,10 +24691,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.startHue = self.startHue.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24771,10 +24776,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader chip::app::Clusters::ColorControl::Commands::StopMoveStep::Type encodableStruct; ListFreer listFreer; { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24880,10 +24885,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.colorTemperatureMaximumMireds = self.colorTemperatureMaximumMireds.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -24995,10 +25000,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.colorTemperatureMaximumMireds = self.colorTemperatureMaximumMireds.unsignedShortValue; } { - encodableStruct.optionsMask = self.optionsMask.unsignedCharValue; + encodableStruct.optionsMask = static_cast>(self.optionsMask.unsignedCharValue); } { - encodableStruct.optionsOverride = self.optionsOverride.unsignedCharValue; + encodableStruct.optionsOverride = static_cast>(self.optionsOverride.unsignedCharValue); } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 3a5968072d5a8d..7d0ab045b6a25a 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -2373,7 +2373,6 @@ INSTALLHDRS_SCRIPT_PHASE = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; - IS_ZIPPERED = YES; LIBRARY_SEARCH_PATHS = "$(TEMP_DIR)/out/lib"; OTHER_CFLAGS = "-fmacro-prefix-map=$(SRCROOT)/CHIP/="; OTHER_CPLUSPLUSFLAGS = ( @@ -2544,7 +2543,6 @@ INSTALLHDRS_SCRIPT_PHASE = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; - IS_ZIPPERED = YES; LIBRARY_SEARCH_PATHS = "$(TEMP_DIR)/out/lib"; OTHER_CFLAGS = "-fmacro-prefix-map=$(SRCROOT)/CHIP/="; OTHER_CPLUSPLUSFLAGS = ( @@ -2565,6 +2563,7 @@ "-Wl,-unexported_symbol,\"___*\"", "-Wl,-unexported_symbol,\"__Unwind_*\"", "-Wl,-unexported_symbol,\"_unw_*\"", + "-Wl,-unexported_symbol,\"_OBJC_IVAR_*\"", "-Wl,-hidden-lCHIP", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -2583,6 +2582,7 @@ "-Wl,-unexported_symbol,\"___*\"", "-Wl,-unexported_symbol,\"__Unwind_*\"", "-Wl,-unexported_symbol,\"_unw_*\"", + "-Wl,-unexported_symbol,\"_OBJC_IVAR_*\"", "-Wl,-hidden-lCHIP", ); PRODUCT_BUNDLE_IDENTIFIER = com.csa.matter; diff --git a/src/platform/silabs/provision/ProvisionStorage.h b/src/platform/silabs/provision/ProvisionStorage.h index 3dbc78076442a7..ff012491ae3d7c 100644 --- a/src/platform/silabs/provision/ProvisionStorage.h +++ b/src/platform/silabs/provision/ProvisionStorage.h @@ -42,7 +42,7 @@ enum ID : uint16_t kFlashAddress = 0x0101, kFlashSize = 0x0102, kFlashPageSize = 0x0103, - kBaseAddress = 0x0104, + kCredsAddress = 0x0104, kCsrFile = 0x0105, // Options, kVersion = 0x0111, @@ -175,7 +175,6 @@ struct Storage : public GenericStorage, CHIP_ERROR Initialize(uint32_t flash_addr = 0, uint32_t flash_size = 0); CHIP_ERROR Commit(); - CHIP_ERROR GetBaseAddress(uint32_t & value); // // Generic Interface @@ -233,6 +232,8 @@ struct Storage : public GenericStorage, // Other // + CHIP_ERROR SetCredentialsBaseAddress(uint32_t addr); + CHIP_ERROR GetCredentialsBaseAddress(uint32_t & addr); CHIP_ERROR GetSetupPayload(chip::MutableCharSpan & value); CHIP_ERROR SetProvisionRequest(bool value); CHIP_ERROR GetProvisionRequest(bool & value); diff --git a/src/platform/silabs/rs911x/ble_config.h b/src/platform/silabs/rs911x/ble_config.h deleted file mode 120000 index 48a308dc911649..00000000000000 --- a/src/platform/silabs/rs911x/ble_config.h +++ /dev/null @@ -1 +0,0 @@ -rsi_ble_config.h \ No newline at end of file diff --git a/src/platform/silabs/rs911x/ble_config.h b/src/platform/silabs/rs911x/ble_config.h new file mode 100644 index 00000000000000..0b8c951b4f63b1 --- /dev/null +++ b/src/platform/silabs/rs911x/ble_config.h @@ -0,0 +1,18 @@ +/******************************************************************************* + * @file ble_config.h + * @brief + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#include diff --git a/src/platform/silabs/rs911x/rsi_ble_config.h b/src/platform/silabs/rs911x/rsi_ble_config.h index f5442578e5d013..781ad80a29e7d7 100644 --- a/src/platform/silabs/rs911x/rsi_ble_config.h +++ b/src/platform/silabs/rs911x/rsi_ble_config.h @@ -24,6 +24,10 @@ #include #endif +#if SL_MATTER_GN_BUILD == 0 +#include "sl_matter_wifi_config.h" +#endif // SL_MATTER_GN_BUILD + /****************************************************** * * Macros * ******************************************************/ @@ -107,7 +111,7 @@ #else #define RSI_BLE_MAX_NBR_ATT_REC (80) -#if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) +#if (EXP_BOARD) #define RSI_BLE_MAX_NBR_PERIPHERALS (3) #else #define RSI_BLE_MAX_NBR_SLAVES (3) diff --git a/src/platform/telink/tlsr9528a_4m_flash.overlay b/src/platform/telink/tlsr9528a_4m_flash.overlay index 0005da2a590ab4..ec88c5742a6568 100644 --- a/src/platform/telink/tlsr9528a_4m_flash.overlay +++ b/src/platform/telink/tlsr9528a_4m_flash.overlay @@ -14,31 +14,35 @@ }; slot0_partition: partition@13000 { label = "image-0"; - reg = <0x13000 0x1ec000>; + reg = <0x13000 0x1ea000>; }; - factory_partition: partition@1ff000 { - label = "factory-data"; - reg = <0x1ff000 0x1000>; + slot1_partition: partition@1fd000 { + label = "image-1"; + reg = <0x1fd000 0x1ea000>; }; - dac_keypair_partition: partition@200000 { - label = "dac-keypair"; - reg = <0x200000 0x1000>; //store dac and key pair. + storage_partition: partition@3e7000 { + label = "storage"; + reg = <0x3e7000 0xf000>; // matter nvs part }; - descriptor_partition: partition@201000 { - label = "sboot-descriptor"; - reg = <0x201000 0x2000>; + dac_keypair_partition: partition@3f6000 { + label = "dac-keypair"; + reg = <0x3f6000 0x1000>; //store dac and key pair. }; - storage_partition: partition@203000 { - label = "storage"; - reg = <0x203000 0xf000>; + factory_partition: partition@3f7000 { + label = "factory-data"; + reg = <0x3f7000 0x1000>; // factory data info }; - slot1_partition: partition@212000 { - label = "image-1"; - reg = <0x212000 0x1ec000>; + secure_partition: partition@3f8000 { + label = "secure"; + reg = <0x3f8000 0x4000>; //secure info ,reserved for secure boot .if not use , can be used by other way . + }; + vendor_rfu_partition: partition@3fc000 { + label = "vendor-rfu"; + reg = <0x3fc000 0x2000>;// reserved for chip extend. }; vendor_partition: partition@3fe000 { label = "vendor-data"; - reg = <0x3fe000 0x2000>; + reg = <0x3fe000 0x2000>;// mac and adc info. }; }; }; diff --git a/src/python_testing/TC_CC_2_2.py b/src/python_testing/TC_CC_2_2.py index 4f6a21b1ba2771..86080efd358456 100644 --- a/src/python_testing/TC_CC_2_2.py +++ b/src/python_testing/TC_CC_2_2.py @@ -137,14 +137,14 @@ async def test_TC_CC_2_2(self): self.step(6) if supports_hs: - cmd = cc.Commands.MoveHue(moveMode=cc.Enums.HueMoveMode.kDown, rate=225) + cmd = cc.Commands.MoveHue(moveMode=cc.Enums.MoveModeEnum.kDown, rate=225) await self.send_single_cmd(cmd) else: self.mark_current_step_skipped() self.step(7) if supports_hs: - cmd = cc.Commands.MoveSaturation(moveMode=cc.Enums.SaturationMoveMode.kDown, rate=225) + cmd = cc.Commands.MoveSaturation(moveMode=cc.Enums.MoveModeEnum.kDown, rate=225) await self.send_single_cmd(cmd) else: self.mark_current_step_skipped() @@ -173,7 +173,7 @@ def check_report_counts(attr: ClusterObjects.ClusterAttributeDescriptor): self.skip_step(15) else: self.step(10) - cmd = cc.Commands.MoveToHue(hue=254, transitionTime=100, direction=cc.Enums.HueDirection.kShortestDistance) + cmd = cc.Commands.MoveToHue(hue=254, transitionTime=100, direction=cc.Enums.DirectionEnum.kShortest) await self.send_single_cmd(cmd) self.step(11) @@ -228,7 +228,7 @@ def check_report_counts(attr: ClusterObjects.ClusterAttributeDescriptor): else: self.step(23) cmd = cc.Commands.EnhancedMoveToHue(enhancedHue=0, transitionTime=100, - direction=cc.Enums.HueDirection.kShortestDistance) + direction=cc.Enums.DirectionEnum.kShortest) await self.send_single_cmd(cmd) self.step(24) diff --git a/src/python_testing/TC_DeviceBasicComposition.py b/src/python_testing/TC_DeviceBasicComposition.py index 7af7b865542e42..72e6e3e2418c8c 100644 --- a/src/python_testing/TC_DeviceBasicComposition.py +++ b/src/python_testing/TC_DeviceBasicComposition.py @@ -775,7 +775,18 @@ def test_TC_IDM_12_1(self): software_version = self.endpoints[0][Clusters.BasicInformation][Clusters.BasicInformation.Attributes.SoftwareVersion] filename = f'device_dump_0x{vid:04X}_0x{pid:04X}_{software_version}.json' dump_device_composition_path = self.user_params.get("dump_device_composition_path", filename) - self.dump_wildcard(dump_device_composition_path) + json_str, txt_str = self.dump_wildcard(dump_device_composition_path) + + # Structured dump so we can pull these back out of the logs + def log_structured_data(start_tag: str, dump_string): + lines = dump_string.splitlines() + logging.info(f'{start_tag}BEGIN ({len(lines)} lines)====') + for line in lines: + logging.info(f'{start_tag}{line}') + logging.info(f'{start_tag}END ====') + + log_structured_data('==== json: ', json_str) + log_structured_data('==== txt: ', txt_str) if __name__ == "__main__": diff --git a/src/python_testing/TC_ICDM_3_4.py b/src/python_testing/TC_ICDM_3_4.py index 61230532178a08..b062da0845e4ea 100644 --- a/src/python_testing/TC_ICDM_3_4.py +++ b/src/python_testing/TC_ICDM_3_4.py @@ -32,7 +32,8 @@ import time import chip.clusters as Clusters -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import (MatterBaseTest, MatterStackState, MatterTestConfig, TestStep, async_test_body, + default_matter_test_main) from mobly import asserts logger = logging.getLogger(__name__) @@ -110,6 +111,16 @@ async def test_TC_ICDM_3_4(self): time.sleep(wait_time_reboot) self.step(3) + if not is_ci: + # since device has rebooted, force establishing a new CASE session by closing it + self.config = MatterTestConfig() + self.stack = MatterStackState(self.config) + devCtrl = self.stack.certificate_authorities[0].adminList[0].NewController( + nodeId=self.config.controller_node_id, + paaTrustStorePath=str(self.config.paa_trust_store_path), + catTags=self.config.controller_cat_tags + ) + devCtrl.CloseSession(self.dut_node_id) icdCounter2 = await self._read_icdm_attribute_expect_success(attribute=attributes.ICDCounter) asserts.assert_greater_equal(icdCounter2, icdCounter1, "ICDCounter have reboot is not greater or equal to the ICDCounter read before the reboot.") diff --git a/src/python_testing/TC_MCORE_FS_1_2.py b/src/python_testing/TC_MCORE_FS_1_2.py index 1085b0fac0a07c..c199225b33f99c 100644 --- a/src/python_testing/TC_MCORE_FS_1_2.py +++ b/src/python_testing/TC_MCORE_FS_1_2.py @@ -19,27 +19,102 @@ # for details about the block below. # -import base64 +import hashlib import logging +import os import queue +import secrets +import signal +import struct +import subprocess import time +import uuid +from dataclasses import dataclass import chip.clusters as Clusters from chip import ChipDeviceCtrl -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from ecdsa.curves import NIST256p +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches from mobly import asserts from TC_SC_3_6 import AttributeChangeAccumulator +# Length of `w0s` and `w1s` elements +WS_LENGTH = NIST256p.baselen + 8 + + +def _generate_verifier(passcode: int, salt: bytes, iterations: int) -> bytes: + ws = hashlib.pbkdf2_hmac('sha256', struct.pack('>> pairing onnetwork 111 {setup_params.passcode}") + def steps_TC_MCORE_FS_1_2(self) -> list[TestStep]: - steps = [TestStep(1, "TH_FSA subscribes to all the Bridged Device Basic Information clusters provided by DUT_FSA to identify the presence of a Bridged Node endpoint with a UniqueID matching the UniqueID provided by the BasicInformationCluster of the TH_SED_DUT."), - TestStep(2, "TH_FSA initiates commissioning of TH_SED_DUT by sending the OpenCommissioningWindow command to the Administrator Commissioning Cluster on the endpoint with the uniqueID matching that of TH_SED_DUT."), - TestStep(3, "TH_FSA completes commissioning of TH_SED_DUT using the Enhanced Commissioning Method."), - TestStep(4, "Commission TH_SED_L onto DUT_FSA’s fabric using the manufacturer specified mechanism."), - TestStep(5, "TH_FSA waits for subscription report from a the Bridged Device Basic Information clusters provided by DUT_FSA to identify the presence of a Bridged Node endpoint with a UniqueID matching the UniqueID provided by the BasicInformationCluster of the TH_SED_L."), - TestStep(6, "TH_FSA initiates commissions of TH_SED_L by sending the OpenCommissioningWindow command to the Administrator Commissioning Cluster on the endpoint with the uniqueID matching that of TH_SED_L."), - TestStep(7, "TH_FSA completes commissioning of TH_SED_L using the Enhanced Commissioning Method.")] + steps = [TestStep(1, "TH subscribes to PartsList attribute of the Descriptor cluster of DUT_FSA endpoint 0."), + TestStep(2, "Follow manufacturer provided instructions to have DUT_FSA commission TH_SERVER"), + TestStep(3, "TH waits up to 30 seconds for subscription report from the PartsList attribute of the Descriptor to contain new endpoint"), + + TestStep(4, "TH uses DUT to open commissioning window to TH_SERVER"), + TestStep(5, "TH commissions TH_SERVER"), + TestStep(6, "TH reads all attributes in Basic Information cluster from TH_SERVER directly"), + TestStep(7, "TH reads all attributes in the Bridged Device Basic Information cluster on new endpoint identified in step 3 from the DUT_FSA")] return steps @property @@ -49,16 +124,21 @@ def default_timeout(self) -> int: @async_test_body async def test_TC_MCORE_FS_1_2(self): self.is_ci = self.check_pics('PICS_SDK_CI_ONLY') + min_report_interval_sec = self.user_params.get("min_report_interval_sec", 0) - max_report_interval_sec = self.user_params.get("max_report_interval_sec", 2) - report_waiting_timeout_delay_sec = self.user_params.get("report_waiting_timeout_delay_sec", 10) + max_report_interval_sec = self.user_params.get("max_report_interval_sec", 30) + th_server_port = self.user_params.get("th_server_port", 5543) + self._th_server_app_path = self.user_params.get("th_server_app_path", None) + if not self._th_server_app_path: + asserts.fail('This test requires a TH_SERVER app. Specify app path with --string-arg th_server_app_path:') + if not os.path.exists(self._th_server_app_path): + asserts.fail(f'The path {self._th_server_app_path} does not exist') self.step(1) - - # Subscribe to the UniqueIDs - unique_id_queue = queue.Queue() + # Subscribe to the PartsList + root_endpoint = 0 subscription_contents = [ - (Clusters.BridgedDeviceBasicInformation.Attributes.UniqueID) # On all endpoints + (root_endpoint, Clusters.Descriptor.Attributes.PartsList) ] sub = await self.default_controller.ReadAttribute( nodeid=self.dut_node_id, @@ -66,82 +146,38 @@ async def test_TC_MCORE_FS_1_2(self): reportInterval=(min_report_interval_sec, max_report_interval_sec), keepSubscriptions=False ) + + parts_list_queue = queue.Queue() attribute_handler = AttributeChangeAccumulator( - name=self.default_controller.name, expected_attribute=Clusters.BridgedDeviceBasicInformation.Attributes.UniqueID, output=unique_id_queue) + name=self.default_controller.name, expected_attribute=Clusters.Descriptor.Attributes.PartsList, output=parts_list_queue) sub.SetAttributeUpdateCallback(attribute_handler) + cached_attributes = sub.GetAttributes() + step_1_dut_parts_list = cached_attributes[root_endpoint][Clusters.Descriptor][Clusters.Descriptor.Attributes.PartsList] - logging.info("Waiting for First BridgedDeviceBasicInformation.") - start_time = time.time() - elapsed = 0 - time_remaining = report_waiting_timeout_delay_sec - - th_sed_dut_bdbi_endpoint = -1 - th_sed_dut_unique_id = -1 - - while time_remaining > 0 and th_sed_dut_bdbi_endpoint < 0: - try: - item = unique_id_queue.get(block=True, timeout=time_remaining) - endpoint, attribute, value = item['endpoint'], item['attribute'], item['value'] - - # Record arrival of an expected subscription change when seen - if attribute == Clusters.BridgedDeviceBasicInformation.Attributes.UniqueID: - th_sed_dut_bdbi_endpoint = endpoint - th_sed_dut_unique_id = value - - except queue.Empty: - # No error, we update timeouts and keep going - pass - - elapsed = time.time() - start_time - time_remaining = report_waiting_timeout_delay_sec - elapsed - - asserts.assert_greater(th_sed_dut_bdbi_endpoint, 0, "Failed to find any BDBI instances with UniqueID present.") - logging.info("Found BDBI with UniqueID (%d) on endpoint %d." % th_sed_dut_unique_id, th_sed_dut_bdbi_endpoint) + asserts.assert_true(type_matches(step_1_dut_parts_list, list), "PartsList is expected to be a list") self.step(2) - - self.sync_passcode = 20202024 - self.th_sed_dut_discriminator = 2222 - cmd = Clusters.AdministratorCommissioning.Commands.OpenCommissioningWindow(commissioningTimeout=3*60, - PAKEPasscodeVerifier=b"+w1qZQR05Zn0bc2LDyNaDAhsrhDS5iRHPTN10+EmNx8E2OpIPC4SjWRDQVOgqcbnXdYMlpiZ168xLBqn1fx9659gGK/7f9Yc6GxpoJH8kwAUYAYyLGsYeEBt1kL6kpXjgA==", - discriminator=self.th_sed_dut_discriminator, - iterations=10000, salt=base64.b64encode(bytes('SaltyMcSalterson', 'utf-8'))) - await self.send_single_cmd(cmd, endpoint=th_sed_dut_bdbi_endpoint, timedRequestTimeoutMs=5000) - - logging.info("Commissioning Window open for TH_SED_DUT.") + setup_params = await self._create_th_server(th_server_port) + self._ask_for_vendor_commissioning_ux_operation(setup_params) self.step(3) - - self.th_sed_dut_nodeid = 1111 - await self.TH_server_controller.CommissionOnNetwork(nodeId=self.th_sed_dut_nodeid, setupPinCode=self.sync_passcode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.th_sed_dut_discriminator) - logging.info("Commissioning TH_SED_DUT complete") - - self.step(4) - if not self.is_ci: - self.wait_for_user_input( - "Commission TH_SED_DUT onto DUT_FSA’s fabric using the manufacturer specified mechanism. (ensure Synchronization is enabled.)") - else: - logging.info("Stopping after step 3 while running in CI to avoid manual steps.") - return - - self.step(5) - - th_sed_later_bdbi_endpoint = -1 - th_sed_later_unique_id = -1 - logging.info("Waiting for Second BridgedDeviceBasicInformation.") + report_waiting_timeout_delay_sec = 30 + logging.info("Waiting for update to PartsList.") start_time = time.time() elapsed = 0 time_remaining = report_waiting_timeout_delay_sec - while time_remaining > 0 and th_sed_later_bdbi_endpoint < 0: + parts_list_endpoint_count_from_step_1 = len(step_1_dut_parts_list) + step_3_dut_parts_list = None + while time_remaining > 0: try: - item = unique_id_queue.get(block=True, timeout=time_remaining) + item = parts_list_queue.get(block=True, timeout=time_remaining) endpoint, attribute, value = item['endpoint'], item['attribute'], item['value'] # Record arrival of an expected subscription change when seen - if attribute == Clusters.BridgedDeviceBasicInformation.Attributes.UniqueID and endpoint != th_sed_dut_bdbi_endpoint and th_sed_later_unique_id != th_sed_dut_unique_id: - th_sed_later_bdbi_endpoint = endpoint - th_sed_later_unique_id = value + if endpoint == root_endpoint and attribute == Clusters.Descriptor.Attributes.PartsList and len(value) > parts_list_endpoint_count_from_step_1: + step_3_dut_parts_list = value + break except queue.Empty: # No error, we update timeouts and keep going @@ -150,26 +186,63 @@ async def test_TC_MCORE_FS_1_2(self): elapsed = time.time() - start_time time_remaining = report_waiting_timeout_delay_sec - elapsed - asserts.assert_greater(th_sed_later_bdbi_endpoint, 0, "Failed to find any BDBI instances with UniqueID present.") - logging.info("Found another BDBI with UniqueID (%d) on endpoint %d." % th_sed_later_unique_id, th_sed_later_bdbi_endpoint) + asserts.assert_not_equal(step_3_dut_parts_list, None, "Timed out getting updated PartsList with new endpoint") + set_of_step_1_parts_list_endpoint = set(step_1_dut_parts_list) + set_of_step_3_parts_list_endpoint = set(step_3_dut_parts_list) + unique_endpoints_set = set_of_step_3_parts_list_endpoint - set_of_step_1_parts_list_endpoint + asserts.assert_equal(len(unique_endpoints_set), 1, "Expected only one new endpoint") + newly_added_endpoint = list(unique_endpoints_set)[0] - self.step(6) + self.step(4) - self.th_sed_later_discriminator = 3333 - # min commissioning timeout is 3*60 seconds, so use that even though the command said 30. + discriminator = 3840 + passcode = 20202021 + salt = secrets.token_bytes(16) + iterations = 2000 + verifier = _generate_verifier(passcode, salt, iterations) + + # min commissioning timeout is 3*60 seconds cmd = Clusters.AdministratorCommissioning.Commands.OpenCommissioningWindow(commissioningTimeout=3*60, - PAKEPasscodeVerifier=b"+w1qZQR05Zn0bc2LDyNaDAhsrhDS5iRHPTN10+EmNx8E2OpIPC4SjWRDQVOgqcbnXdYMlpiZ168xLBqn1fx9659gGK/7f9Yc6GxpoJH8kwAUYAYyLGsYeEBt1kL6kpXjgA==", - discriminator=self.th_sed_later_discriminator, - iterations=10000, salt=base64.b64encode(bytes('SaltyMcSalterson', 'utf-8'))) - await self.send_single_cmd(cmd, endpoint=th_sed_later_bdbi_endpoint, timedRequestTimeoutMs=5000) + PAKEPasscodeVerifier=verifier, + discriminator=discriminator, + iterations=iterations, + salt=salt) + await self.send_single_cmd(cmd, dev_ctrl=self.default_controller, node_id=self.dut_node_id, endpoint=newly_added_endpoint, timedRequestTimeoutMs=5000) - logging.info("Commissioning Window open for TH_SED_L.") + self.step(5) + self.th_server_local_nodeid = 1111 + await self.default_controller.CommissionOnNetwork(nodeId=self.th_server_local_nodeid, setupPinCode=passcode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=discriminator) - self.step(7) + self.step(6) + th_server_directly_read_result = await self.default_controller.ReadAttribute(self.th_server_local_nodeid, [(root_endpoint, Clusters.BasicInformation)]) + th_server_basic_info = th_server_directly_read_result[root_endpoint][Clusters.BasicInformation] - self.th_sed_later_nodeid = 2222 - await self.TH_server_controller.CommissionOnNetwork(nodeId=self.th_sed_later_nodeid, setupPinCode=self.sync_passcode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.th_sed_later_discriminator) - logging.info("Commissioning TH_SED_L complete") + self.step(7) + dut_read = await self.default_controller.ReadAttribute(self.dut_node_id, [(newly_added_endpoint, Clusters.BridgedDeviceBasicInformation)]) + bridged_info_for_th_server = dut_read[newly_added_endpoint][Clusters.BridgedDeviceBasicInformation] + basic_info_attr = Clusters.BasicInformation.Attributes + bridged_device_info_attr = Clusters.BridgedDeviceBasicInformation.Attributes + Clusters.BasicInformation.Attributes + asserts.assert_equal(th_server_basic_info[basic_info_attr.VendorName], + bridged_info_for_th_server[bridged_device_info_attr.VendorName], "VendorName incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.VendorID], + bridged_info_for_th_server[bridged_device_info_attr.VendorID], "VendorID incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.ProductName], + bridged_info_for_th_server[bridged_device_info_attr.ProductName], "ProductName incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.ProductID], + bridged_info_for_th_server[bridged_device_info_attr.ProductID], "ProductID incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.NodeLabel], + bridged_info_for_th_server[bridged_device_info_attr.NodeLabel], "NodeLabel incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.HardwareVersion], + bridged_info_for_th_server[bridged_device_info_attr.HardwareVersion], "HardwareVersion incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.HardwareVersionString], + bridged_info_for_th_server[bridged_device_info_attr.HardwareVersionString], "HardwareVersionString incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.SoftwareVersion], + bridged_info_for_th_server[bridged_device_info_attr.SoftwareVersion], "SoftwareVersion incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.SoftwareVersionString], + bridged_info_for_th_server[bridged_device_info_attr.SoftwareVersionString], "SoftwareVersionString incorrectly reported by DUT") + asserts.assert_equal(th_server_basic_info[basic_info_attr.UniqueID], + bridged_info_for_th_server[bridged_device_info_attr.UniqueID], "UniqueID incorrectly reported by DUT") if __name__ == "__main__": diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index edc72f253eead5..45d5b0918a76f2 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -1264,8 +1264,8 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1): sub_handler = ClusterAttributeChangeAccumulator(cluster) await sub_handler.start(self.default_controller, self.dut_node_id, endpoint) - self.step(3) if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")): + self.step(3) self.send_manual_or_pipe_command(name="OperationalStateChange", device=self.device, operation="Start") diff --git a/src/python_testing/basic_composition_support.py b/src/python_testing/basic_composition_support.py index 678c249d0abf5d..e25de55c0441a9 100644 --- a/src/python_testing/basic_composition_support.py +++ b/src/python_testing/basic_composition_support.py @@ -23,7 +23,7 @@ import pathlib import sys import typing -from pprint import pprint +from pprint import pformat, pprint from typing import Any, Optional import chip.clusters.ClusterObjects @@ -105,15 +105,20 @@ async def connect_over_pase(self, dev_ctrl): asserts.assert_equal(len(setupCode), 1, "Require one of either --qr-code or --manual-code.") await dev_ctrl.FindOrEstablishPASESession(setupCode[0], self.dut_node_id) - def dump_wildcard(self, dump_device_composition_path: typing.Optional[str]): + def dump_wildcard(self, dump_device_composition_path: typing.Optional[str]) -> tuple[str, str]: + """ Dumps a json and a txt file of the attribute wildcard for this device if the dump_device_composition_path is supplied. + Returns the json and txt as strings. + """ node_dump_dict = {endpoint_id: MatterTlvToJson(self.endpoints_tlv[endpoint_id]) for endpoint_id in self.endpoints_tlv} - logging.debug(f"Raw TLV contents of Node: {json.dumps(node_dump_dict, indent=2)}") + json_dump_string = json.dumps(node_dump_dict, indent=2) + logging.debug(f"Raw TLV contents of Node: {json_dump_string}") if dump_device_composition_path is not None: with open(pathlib.Path(dump_device_composition_path).with_suffix(".json"), "wt+") as outfile: json.dump(node_dump_dict, outfile, indent=2) with open(pathlib.Path(dump_device_composition_path).with_suffix(".txt"), "wt+") as outfile: pprint(self.endpoints, outfile, indent=1, width=200, compact=True) + return (json_dump_string, pformat(self.endpoints, indent=1, width=200, compact=True)) async def setup_class_helper(self, default_to_pase: bool = True): dev_ctrl = self.default_controller diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 8c7635ad9235d3..1163cd28c99de3 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -27,17 +27,8 @@ import("silabs_board.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" declare_args() { - # Enable the Alarm Based Wakeup for 917 SoC when sleep is enabled - si91x_alarm_based_periodic_wakeup = false - - # Periodic time at which the 917 SoC should wakeup - si91x_alarm_periodic_time = 30 - # option to select the crypto library sl_si91x_crypto_flavor = "tinycrypt" - - # enable 917 SoC M4 sleep wakeup - si917_m4_sleep_enabled = false } # Defines an siwx917 SDK build target. @@ -325,17 +316,6 @@ template("siwx917_sdk") { "SL_SI91X_POWER_MANAGER_UC_AVAILABLE=1", "SL_SI91X_TICKLESS_MODE=1", ] - - if (si91x_alarm_based_periodic_wakeup) { - defines += [ "ALARM_PERIODIC_TIME=${si91x_alarm_periodic_time}" ] - } - - if (si917_m4_sleep_enabled) { - defines += [ - "SI917_M4_SLEEP_ENABLED=1", - "XTAL_OFF", - ] - } } if (sl_uart_log_output) { diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index c9126d02e43a9f..617dfd10facb95 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -485,6 +485,8 @@ template("efr32_sdk") { "RSI_LITTLE_ENDIAN=1", "SLI_SI91X_ENABLE_BLE=1", "SL_SI91X_ENABLE_LITTLE_ENDIAN=1", + "RSI_BLE_MAX_NBR_PERIPHERALS=1", + "RSI_BLE_MAX_NBR_CENTRALS=1", ] } diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 8f476b30f9c604..e313f2dc9663da 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 8f476b30f9c6041de334abadcdb6852ade77790e +Subproject commit e313f2dc9663da1ee4488eceba17dbff038f6a63 diff --git a/third_party/silabs/simplicity_sdk b/third_party/silabs/simplicity_sdk index a1a37fa7dda1f7..aa5ce2e835dfdc 160000 --- a/third_party/silabs/simplicity_sdk +++ b/third_party/silabs/simplicity_sdk @@ -1 +1 @@ -Subproject commit a1a37fa7dda1f76ea70229aa4ffe2e47cb066edc +Subproject commit aa5ce2e835dfdce8c20fb828f27d3a261946f946 diff --git a/third_party/silabs/wifi_sdk b/third_party/silabs/wifi_sdk index e97a0ed00ddda3..841ea3f7e0e8ce 160000 --- a/third_party/silabs/wifi_sdk +++ b/third_party/silabs/wifi_sdk @@ -1 +1 @@ -Subproject commit e97a0ed00ddda347a8a39e8276f470e1c5fea469 +Subproject commit 841ea3f7e0e8ce64a160ae2354e747260a61b1e9 diff --git a/third_party/silabs/wiseconnect-wifi-bt-sdk b/third_party/silabs/wiseconnect-wifi-bt-sdk index c3843e95e63f84..f94b83d050fe62 160000 --- a/third_party/silabs/wiseconnect-wifi-bt-sdk +++ b/third_party/silabs/wiseconnect-wifi-bt-sdk @@ -1 +1 @@ -Subproject commit c3843e95e63f84e301a2727f7b3c26125818b53a +Subproject commit f94b83d050fe6200c5ec2dacfafa2edc92ad5ef3 diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index c5768be8b71f3d..a8fc013fa0ce19 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -27161,9 +27161,9 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu namespace DriftCompensation { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value) +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::DriftCompensationEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); Protocols::InteractionModel::Status status = @@ -27177,9 +27177,10 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * val return status; } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::DriftCompensationEnum value, + MarkAttributeDirty markDirty) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -27190,9 +27191,9 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value return emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE, markDirty); } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::DriftCompensationEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -27299,9 +27300,9 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu namespace ColorMode { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value) +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::ColorModeEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); Protocols::InteractionModel::Status status = @@ -27315,9 +27316,10 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * val return status; } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::ColorModeEnum value, + MarkAttributeDirty markDirty) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -27328,9 +27330,9 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value return emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE, markDirty); } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::ColorModeEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -27345,9 +27347,10 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value namespace Options { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value) +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + chip::BitMask * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); Protocols::InteractionModel::Status status = @@ -27361,9 +27364,10 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * val return status; } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty) +Protocols::InteractionModel::Status +Set(chip::EndpointId endpoint, chip::BitMask value, MarkAttributeDirty markDirty) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -27374,9 +27378,10 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value return emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, Id, writable, ZCL_BITMAP8_ATTRIBUTE_TYPE, markDirty); } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + chip::BitMask value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -29237,9 +29242,9 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu namespace EnhancedColorMode { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value) +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorModeEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); Protocols::InteractionModel::Status status = @@ -29253,9 +29258,10 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * val return status; } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorModeEnum value, + MarkAttributeDirty markDirty) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -29266,9 +29272,9 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value return emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE, markDirty); } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorModeEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -29513,9 +29519,10 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu namespace ColorCapabilities { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value) +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + chip::BitMask * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); Protocols::InteractionModel::Status status = @@ -29529,9 +29536,11 @@ Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * va return status; } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + chip::BitMask value, + MarkAttributeDirty markDirty) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; @@ -29542,9 +29551,10 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu return emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, Id, writable, ZCL_BITMAP16_ATTRIBUTE_TYPE, markDirty); } -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value) +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + chip::BitMask value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return Protocols::InteractionModel::Status::ConstraintError; diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 41422b72ca596d..cab9691ebbf4ed 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -4267,9 +4267,11 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu } // namespace CurrentY namespace DriftCompensation { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value); // enum8 -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty); +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + chip::app::Clusters::ColorControl::DriftCompensationEnum * value); // DriftCompensationEnum +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::DriftCompensationEnum value); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::DriftCompensationEnum value, + MarkAttributeDirty markDirty); } // namespace DriftCompensation namespace CompensationText { @@ -4285,15 +4287,20 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu } // namespace ColorTemperatureMireds namespace ColorMode { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value); // enum8 -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty); +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + chip::app::Clusters::ColorControl::ColorModeEnum * value); // ColorModeEnum +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::ColorModeEnum value); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::ColorModeEnum value, + MarkAttributeDirty markDirty); } // namespace ColorMode namespace Options { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value); // bitmap8 -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty); +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + chip::BitMask * value); // OptionsBitmap +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + chip::BitMask value); +Protocols::InteractionModel::Status +Set(chip::EndpointId endpoint, chip::BitMask value, MarkAttributeDirty markDirty); } // namespace Options namespace NumberOfPrimaries { @@ -4533,9 +4540,11 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu } // namespace EnhancedCurrentHue namespace EnhancedColorMode { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value); // enum8 -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty); +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + chip::app::Clusters::ColorControl::EnhancedColorModeEnum * value); // EnhancedColorModeEnum +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorModeEnum value); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorModeEnum value, + MarkAttributeDirty markDirty); } // namespace EnhancedColorMode namespace ColorLoopActive { @@ -4569,9 +4578,14 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu } // namespace ColorLoopStoredEnhancedHue namespace ColorCapabilities { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value); // bitmap16 -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty); +Protocols::InteractionModel::Status +Get(chip::EndpointId endpoint, + chip::BitMask * value); // ColorCapabilitiesBitmap +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + chip::BitMask value); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + chip::BitMask value, + MarkAttributeDirty markDirty); } // namespace ColorCapabilities namespace ColorTempPhysicalMinMireds { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index da2047e745d586..f63782c221d827 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -2942,9 +2942,9 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ThermostatUserInterface } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoopAction val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoopActionEnum val) { - using EnumType = ColorControl::ColorLoopAction; + using EnumType = ColorControl::ColorLoopActionEnum; switch (val) { case EnumType::kDeactivate: @@ -2955,38 +2955,38 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoop return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoopDirection val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorLoopDirectionEnum val) { - using EnumType = ColorControl::ColorLoopDirection; + using EnumType = ColorControl::ColorLoopDirectionEnum; switch (val) { - case EnumType::kDecrementHue: - case EnumType::kIncrementHue: + case EnumType::kDecrement: + case EnumType::kIncrement: return val; default: return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorMode val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::ColorModeEnum val) { - using EnumType = ColorControl::ColorMode; + using EnumType = ColorControl::ColorModeEnum; switch (val) { case EnumType::kCurrentHueAndCurrentSaturation: case EnumType::kCurrentXAndCurrentY: - case EnumType::kColorTemperature: + case EnumType::kColorTemperatureMireds: return val; default: return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueDirection val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::DirectionEnum val) { - using EnumType = ColorControl::HueDirection; + using EnumType = ColorControl::DirectionEnum; switch (val) { - case EnumType::kShortestDistance: - case EnumType::kLongestDistance: + case EnumType::kShortest: + case EnumType::kLongest: case EnumType::kUp: case EnumType::kDown: return val; @@ -2994,34 +2994,38 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueDirect return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueMoveMode val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::DriftCompensationEnum val) { - using EnumType = ColorControl::HueMoveMode; + using EnumType = ColorControl::DriftCompensationEnum; switch (val) { - case EnumType::kStop: - case EnumType::kUp: - case EnumType::kDown: + case EnumType::kNone: + case EnumType::kOtherOrUnknown: + case EnumType::kTemperatureMonitoring: + case EnumType::kOpticalLuminanceMonitoringAndFeedback: + case EnumType::kOpticalColorMonitoringAndFeedback: return val; default: return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::HueStepMode val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::EnhancedColorModeEnum val) { - using EnumType = ColorControl::HueStepMode; + using EnumType = ColorControl::EnhancedColorModeEnum; switch (val) { - case EnumType::kUp: - case EnumType::kDown: + case EnumType::kCurrentHueAndCurrentSaturation: + case EnumType::kCurrentXAndCurrentY: + case EnumType::kColorTemperatureMireds: + case EnumType::kEnhancedCurrentHueAndCurrentSaturation: return val; default: return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::SaturationMoveMode val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::MoveModeEnum val) { - using EnumType = ColorControl::SaturationMoveMode; + using EnumType = ColorControl::MoveModeEnum; switch (val) { case EnumType::kStop: @@ -3032,9 +3036,9 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::Saturatio return EnumType::kUnknownEnumValue; } } -static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::SaturationStepMode val) +static auto __attribute__((unused)) EnsureKnownEnumValue(ColorControl::StepModeEnum val) { - using EnumType = ColorControl::SaturationStepMode; + using EnumType = ColorControl::StepModeEnum; switch (val) { case EnumType::kUp: diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 571439625e121a..e78f8f4d064648 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -4343,8 +4343,8 @@ enum class TemperatureDisplayModeEnum : uint8_t namespace ColorControl { -// Enum for ColorLoopAction -enum class ColorLoopAction : uint8_t +// Enum for ColorLoopActionEnum +enum class ColorLoopActionEnum : uint8_t { kDeactivate = 0x00, kActivateFromColorLoopStartEnhancedHue = 0x01, @@ -4356,11 +4356,11 @@ enum class ColorLoopAction : uint8_t kUnknownEnumValue = 3, }; -// Enum for ColorLoopDirection -enum class ColorLoopDirection : uint8_t +// Enum for ColorLoopDirectionEnum +enum class ColorLoopDirectionEnum : uint8_t { - kDecrementHue = 0x00, - kIncrementHue = 0x01, + kDecrement = 0x00, + kIncrement = 0x01, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown @@ -4368,12 +4368,12 @@ enum class ColorLoopDirection : uint8_t kUnknownEnumValue = 2, }; -// Enum for ColorMode -enum class ColorMode : uint8_t +// Enum for ColorModeEnum +enum class ColorModeEnum : uint8_t { kCurrentHueAndCurrentSaturation = 0x00, kCurrentXAndCurrentY = 0x01, - kColorTemperature = 0x02, + kColorTemperatureMireds = 0x02, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown @@ -4381,13 +4381,13 @@ enum class ColorMode : uint8_t kUnknownEnumValue = 3, }; -// Enum for HueDirection -enum class HueDirection : uint8_t +// Enum for DirectionEnum +enum class DirectionEnum : uint8_t { - kShortestDistance = 0x00, - kLongestDistance = 0x01, - kUp = 0x02, - kDown = 0x03, + kShortest = 0x00, + kLongest = 0x01, + kUp = 0x02, + kDown = 0x03, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown @@ -4395,33 +4395,37 @@ enum class HueDirection : uint8_t kUnknownEnumValue = 4, }; -// Enum for HueMoveMode -enum class HueMoveMode : uint8_t +// Enum for DriftCompensationEnum +enum class DriftCompensationEnum : uint8_t { - kStop = 0x00, - kUp = 0x01, - kDown = 0x03, + kNone = 0x00, + kOtherOrUnknown = 0x01, + kTemperatureMonitoring = 0x02, + kOpticalLuminanceMonitoringAndFeedback = 0x03, + kOpticalColorMonitoringAndFeedback = 0x04, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. - kUnknownEnumValue = 2, + kUnknownEnumValue = 5, }; -// Enum for HueStepMode -enum class HueStepMode : uint8_t +// Enum for EnhancedColorModeEnum +enum class EnhancedColorModeEnum : uint8_t { - kUp = 0x01, - kDown = 0x03, + kCurrentHueAndCurrentSaturation = 0x00, + kCurrentXAndCurrentY = 0x01, + kColorTemperatureMireds = 0x02, + kEnhancedCurrentHueAndCurrentSaturation = 0x03, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + kUnknownEnumValue = 4, }; -// Enum for SaturationMoveMode -enum class SaturationMoveMode : uint8_t +// Enum for MoveModeEnum +enum class MoveModeEnum : uint8_t { kStop = 0x00, kUp = 0x01, @@ -4433,8 +4437,8 @@ enum class SaturationMoveMode : uint8_t kUnknownEnumValue = 2, }; -// Enum for SaturationStepMode -enum class SaturationStepMode : uint8_t +// Enum for StepModeEnum +enum class StepModeEnum : uint8_t { kUp = 0x01, kDown = 0x03, @@ -4445,23 +4449,14 @@ enum class SaturationStepMode : uint8_t kUnknownEnumValue = 0, }; -// Bitmap for ColorCapabilities -enum class ColorCapabilities : uint16_t +// Bitmap for ColorCapabilitiesBitmap +enum class ColorCapabilitiesBitmap : uint16_t { - kHueSaturationSupported = 0x1, - kEnhancedHueSupported = 0x2, - kColorLoopSupported = 0x4, - kXYAttributesSupported = 0x8, - kColorTemperatureSupported = 0x10, -}; - -// Bitmap for ColorLoopUpdateFlags -enum class ColorLoopUpdateFlags : uint8_t -{ - kUpdateAction = 0x1, - kUpdateDirection = 0x2, - kUpdateTime = 0x4, - kUpdateStartHue = 0x8, + kHueSaturation = 0x1, + kEnhancedHue = 0x2, + kColorLoop = 0x4, + kXy = 0x8, + kColorTemperature = 0x10, }; // Bitmap for Feature @@ -4473,6 +4468,21 @@ enum class Feature : uint32_t kXy = 0x8, kColorTemperature = 0x10, }; + +// Bitmap for OptionsBitmap +enum class OptionsBitmap : uint8_t +{ + kExecuteIfOff = 0x1, +}; + +// Bitmap for UpdateFlagsBitmap +enum class UpdateFlagsBitmap : uint8_t +{ + kUpdateAction = 0x1, + kUpdateDirection = 0x2, + kUpdateTime = 0x4, + kUpdateStartHue = 0x8, +}; } // namespace ColorControl namespace BallastConfiguration { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index f0f1dea1de536d..c2c1697ce271f3 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -30149,7 +30149,7 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::SetActivePresetRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::Thermostat::Id; } - chip::ByteSpan presetHandle; + DataModel::Nullable presetHandle; CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -30164,7 +30164,7 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::SetActivePresetRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::Thermostat::Id; } - chip::ByteSpan presetHandle; + DataModel::Nullable presetHandle; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace SetActivePresetRequest @@ -31602,11 +31602,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveToHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t hue = static_cast(0); - HueDirection direction = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint8_t hue = static_cast(0); + DirectionEnum direction = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31621,11 +31621,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveToHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t hue = static_cast(0); - HueDirection direction = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint8_t hue = static_cast(0); + DirectionEnum direction = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveToHue @@ -31645,10 +31645,10 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueMoveMode moveMode = static_cast(0); - uint8_t rate = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint8_t rate = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31663,10 +31663,10 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueMoveMode moveMode = static_cast(0); - uint8_t rate = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint8_t rate = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveHue @@ -31687,11 +31687,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::StepHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueStepMode stepMode = static_cast(0); - uint8_t stepSize = static_cast(0); - uint8_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint8_t stepSize = static_cast(0); + uint8_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31706,11 +31706,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::StepHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueStepMode stepMode = static_cast(0); - uint8_t stepSize = static_cast(0); - uint8_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint8_t stepSize = static_cast(0); + uint8_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StepHue @@ -31730,10 +31730,10 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveToSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t saturation = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint8_t saturation = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31748,10 +31748,10 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveToSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t saturation = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint8_t saturation = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveToSaturation @@ -31771,10 +31771,10 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - SaturationMoveMode moveMode = static_cast(0); - uint8_t rate = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint8_t rate = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31789,10 +31789,10 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - SaturationMoveMode moveMode = static_cast(0); - uint8_t rate = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint8_t rate = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveSaturation @@ -31813,11 +31813,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::StepSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - SaturationStepMode stepMode = static_cast(0); - uint8_t stepSize = static_cast(0); - uint8_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint8_t stepSize = static_cast(0); + uint8_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31832,11 +31832,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::StepSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - SaturationStepMode stepMode = static_cast(0); - uint8_t stepSize = static_cast(0); - uint8_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint8_t stepSize = static_cast(0); + uint8_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StepSaturation @@ -31857,11 +31857,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveToHueAndSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t hue = static_cast(0); - uint8_t saturation = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint8_t hue = static_cast(0); + uint8_t saturation = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31876,11 +31876,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveToHueAndSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t hue = static_cast(0); - uint8_t saturation = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint8_t hue = static_cast(0); + uint8_t saturation = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveToHueAndSaturation @@ -31901,11 +31901,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveToColor::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t colorX = static_cast(0); - uint16_t colorY = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t colorX = static_cast(0); + uint16_t colorY = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31920,11 +31920,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveToColor::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t colorX = static_cast(0); - uint16_t colorY = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t colorX = static_cast(0); + uint16_t colorY = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveToColor @@ -31944,10 +31944,10 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveColor::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - int16_t rateX = static_cast(0); - int16_t rateY = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + int16_t rateX = static_cast(0); + int16_t rateY = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -31962,10 +31962,10 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveColor::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - int16_t rateX = static_cast(0); - int16_t rateY = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + int16_t rateX = static_cast(0); + int16_t rateY = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveColor @@ -31986,11 +31986,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::StepColor::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - int16_t stepX = static_cast(0); - int16_t stepY = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + int16_t stepX = static_cast(0); + int16_t stepY = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32005,11 +32005,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::StepColor::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - int16_t stepX = static_cast(0); - int16_t stepY = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + int16_t stepX = static_cast(0); + int16_t stepY = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StepColor @@ -32029,10 +32029,10 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveToColorTemperature::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t colorTemperatureMireds = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t colorTemperatureMireds = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32047,10 +32047,10 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveToColorTemperature::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t colorTemperatureMireds = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t colorTemperatureMireds = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveToColorTemperature @@ -32071,11 +32071,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::EnhancedMoveToHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t enhancedHue = static_cast(0); - HueDirection direction = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t enhancedHue = static_cast(0); + DirectionEnum direction = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32090,11 +32090,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::EnhancedMoveToHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t enhancedHue = static_cast(0); - HueDirection direction = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t enhancedHue = static_cast(0); + DirectionEnum direction = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace EnhancedMoveToHue @@ -32114,10 +32114,10 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::EnhancedMoveHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueMoveMode moveMode = static_cast(0); - uint16_t rate = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint16_t rate = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32132,10 +32132,10 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::EnhancedMoveHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueMoveMode moveMode = static_cast(0); - uint16_t rate = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint16_t rate = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace EnhancedMoveHue @@ -32156,11 +32156,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::EnhancedStepHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueStepMode stepMode = static_cast(0); - uint16_t stepSize = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint16_t stepSize = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32175,11 +32175,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::EnhancedStepHue::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueStepMode stepMode = static_cast(0); - uint16_t stepSize = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint16_t stepSize = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace EnhancedStepHue @@ -32200,11 +32200,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::EnhancedMoveToHueAndSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t enhancedHue = static_cast(0); - uint8_t saturation = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t enhancedHue = static_cast(0); + uint8_t saturation = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32219,11 +32219,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::EnhancedMoveToHueAndSaturation::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint16_t enhancedHue = static_cast(0); - uint8_t saturation = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + uint16_t enhancedHue = static_cast(0); + uint8_t saturation = static_cast(0); + uint16_t transitionTime = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace EnhancedMoveToHueAndSaturation @@ -32246,13 +32246,13 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::ColorLoopSet::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - chip::BitMask updateFlags = static_cast>(0); - ColorLoopAction action = static_cast(0); - ColorLoopDirection direction = static_cast(0); - uint16_t time = static_cast(0); - uint16_t startHue = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + chip::BitMask updateFlags = static_cast>(0); + ColorLoopActionEnum action = static_cast(0); + ColorLoopDirectionEnum direction = static_cast(0); + uint16_t time = static_cast(0); + uint16_t startHue = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32267,13 +32267,13 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::ColorLoopSet::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - chip::BitMask updateFlags = static_cast>(0); - ColorLoopAction action = static_cast(0); - ColorLoopDirection direction = static_cast(0); - uint16_t time = static_cast(0); - uint16_t startHue = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + chip::BitMask updateFlags = static_cast>(0); + ColorLoopActionEnum action = static_cast(0); + ColorLoopDirectionEnum direction = static_cast(0); + uint16_t time = static_cast(0); + uint16_t startHue = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace ColorLoopSet @@ -32291,8 +32291,8 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::StopMoveStep::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32307,8 +32307,8 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::StopMoveStep::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StopMoveStep @@ -32330,12 +32330,12 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::MoveColorTemperature::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueMoveMode moveMode = static_cast(0); - uint16_t rate = static_cast(0); - uint16_t colorTemperatureMinimumMireds = static_cast(0); - uint16_t colorTemperatureMaximumMireds = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint16_t rate = static_cast(0); + uint16_t colorTemperatureMinimumMireds = static_cast(0); + uint16_t colorTemperatureMaximumMireds = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32350,12 +32350,12 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::MoveColorTemperature::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueMoveMode moveMode = static_cast(0); - uint16_t rate = static_cast(0); - uint16_t colorTemperatureMinimumMireds = static_cast(0); - uint16_t colorTemperatureMaximumMireds = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + MoveModeEnum moveMode = static_cast(0); + uint16_t rate = static_cast(0); + uint16_t colorTemperatureMinimumMireds = static_cast(0); + uint16_t colorTemperatureMaximumMireds = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace MoveColorTemperature @@ -32378,13 +32378,13 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::StepColorTemperature::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueStepMode stepMode = static_cast(0); - uint16_t stepSize = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint16_t colorTemperatureMinimumMireds = static_cast(0); - uint16_t colorTemperatureMaximumMireds = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint16_t stepSize = static_cast(0); + uint16_t transitionTime = static_cast(0); + uint16_t colorTemperatureMinimumMireds = static_cast(0); + uint16_t colorTemperatureMaximumMireds = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -32399,13 +32399,13 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::StepColorTemperature::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } - HueStepMode stepMode = static_cast(0); - uint16_t stepSize = static_cast(0); - uint16_t transitionTime = static_cast(0); - uint16_t colorTemperatureMinimumMireds = static_cast(0); - uint16_t colorTemperatureMaximumMireds = static_cast(0); - uint8_t optionsMask = static_cast(0); - uint8_t optionsOverride = static_cast(0); + StepModeEnum stepMode = static_cast(0); + uint16_t stepSize = static_cast(0); + uint16_t transitionTime = static_cast(0); + uint16_t colorTemperatureMinimumMireds = static_cast(0); + uint16_t colorTemperatureMaximumMireds = static_cast(0); + chip::BitMask optionsMask = static_cast>(0); + chip::BitMask optionsOverride = static_cast>(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StepColorTemperature @@ -32476,9 +32476,9 @@ struct TypeInfo namespace DriftCompensation { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::app::Clusters::ColorControl::DriftCompensationEnum; + using DecodableType = chip::app::Clusters::ColorControl::DriftCompensationEnum; + using DecodableArgType = chip::app::Clusters::ColorControl::DriftCompensationEnum; static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::DriftCompensation::Id; } @@ -32513,9 +32513,9 @@ struct TypeInfo namespace ColorMode { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::app::Clusters::ColorControl::ColorModeEnum; + using DecodableType = chip::app::Clusters::ColorControl::ColorModeEnum; + using DecodableArgType = chip::app::Clusters::ColorControl::ColorModeEnum; static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::ColorMode::Id; } @@ -32525,9 +32525,9 @@ struct TypeInfo namespace Options { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::BitMask; + using DecodableType = chip::BitMask; + using DecodableArgType = chip::BitMask; static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::Options::Id; } @@ -32909,9 +32909,9 @@ struct TypeInfo namespace EnhancedColorMode { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::app::Clusters::ColorControl::EnhancedColorModeEnum; + using DecodableType = chip::app::Clusters::ColorControl::EnhancedColorModeEnum; + using DecodableArgType = chip::app::Clusters::ColorControl::EnhancedColorModeEnum; static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::EnhancedColorMode::Id; } @@ -32981,9 +32981,9 @@ struct TypeInfo namespace ColorCapabilities { struct TypeInfo { - using Type = uint16_t; - using DecodableType = uint16_t; - using DecodableArgType = uint16_t; + using Type = chip::BitMask; + using DecodableType = chip::BitMask; + using DecodableArgType = chip::BitMask; static constexpr ClusterId GetClusterId() { return Clusters::ColorControl::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::ColorCapabilities::Id; } @@ -33088,11 +33088,13 @@ struct TypeInfo Attributes::RemainingTime::TypeInfo::DecodableType remainingTime = static_cast(0); Attributes::CurrentX::TypeInfo::DecodableType currentX = static_cast(0); Attributes::CurrentY::TypeInfo::DecodableType currentY = static_cast(0); - Attributes::DriftCompensation::TypeInfo::DecodableType driftCompensation = static_cast(0); + Attributes::DriftCompensation::TypeInfo::DecodableType driftCompensation = + static_cast(0); Attributes::CompensationText::TypeInfo::DecodableType compensationText; Attributes::ColorTemperatureMireds::TypeInfo::DecodableType colorTemperatureMireds = static_cast(0); - Attributes::ColorMode::TypeInfo::DecodableType colorMode = static_cast(0); - Attributes::Options::TypeInfo::DecodableType options = static_cast(0); + Attributes::ColorMode::TypeInfo::DecodableType colorMode = static_cast(0); + Attributes::Options::TypeInfo::DecodableType options = + static_cast>(0); Attributes::NumberOfPrimaries::TypeInfo::DecodableType numberOfPrimaries; Attributes::Primary1X::TypeInfo::DecodableType primary1X = static_cast(0); Attributes::Primary1Y::TypeInfo::DecodableType primary1Y = static_cast(0); @@ -33123,14 +33125,16 @@ struct TypeInfo Attributes::ColorPointBX::TypeInfo::DecodableType colorPointBX = static_cast(0); Attributes::ColorPointBY::TypeInfo::DecodableType colorPointBY = static_cast(0); Attributes::ColorPointBIntensity::TypeInfo::DecodableType colorPointBIntensity; - Attributes::EnhancedCurrentHue::TypeInfo::DecodableType enhancedCurrentHue = static_cast(0); - Attributes::EnhancedColorMode::TypeInfo::DecodableType enhancedColorMode = static_cast(0); + Attributes::EnhancedCurrentHue::TypeInfo::DecodableType enhancedCurrentHue = static_cast(0); + Attributes::EnhancedColorMode::TypeInfo::DecodableType enhancedColorMode = + static_cast(0); Attributes::ColorLoopActive::TypeInfo::DecodableType colorLoopActive = static_cast(0); Attributes::ColorLoopDirection::TypeInfo::DecodableType colorLoopDirection = static_cast(0); Attributes::ColorLoopTime::TypeInfo::DecodableType colorLoopTime = static_cast(0); Attributes::ColorLoopStartEnhancedHue::TypeInfo::DecodableType colorLoopStartEnhancedHue = static_cast(0); Attributes::ColorLoopStoredEnhancedHue::TypeInfo::DecodableType colorLoopStoredEnhancedHue = static_cast(0); - Attributes::ColorCapabilities::TypeInfo::DecodableType colorCapabilities = static_cast(0); + Attributes::ColorCapabilities::TypeInfo::DecodableType colorCapabilities = + static_cast>(0); Attributes::ColorTempPhysicalMinMireds::TypeInfo::DecodableType colorTempPhysicalMinMireds = static_cast(0); Attributes::ColorTempPhysicalMaxMireds::TypeInfo::DecodableType colorTempPhysicalMaxMireds = static_cast(0); Attributes::CoupleColorTempToLevelMinMireds::TypeInfo::DecodableType coupleColorTempToLevelMinMireds = diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 57259e33d69d44..add8258f1e9db3 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -23695,16 +23695,17 @@ void registerClusterColorControl(Commands & commands, CredentialIssuerCommands * WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "current-y", 0, UINT16_MAX, Attributes::CurrentY::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "drift-compensation", 0, UINT8_MAX, Attributes::DriftCompensation::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>( + Id, "drift-compensation", 0, UINT8_MAX, Attributes::DriftCompensation::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // make_unique>(Id, "compensation-text", Attributes::CompensationText::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "color-temperature-mireds", 0, UINT16_MAX, Attributes::ColorTemperatureMireds::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "color-mode", 0, UINT8_MAX, Attributes::ColorMode::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "options", 0, UINT8_MAX, Attributes::Options::Id, WriteCommandType::kWrite, - credsIssuerConfig), // + make_unique>( + Id, "color-mode", 0, UINT8_MAX, Attributes::ColorMode::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "options", 0, UINT8_MAX, Attributes::Options::Id, WriteCommandType::kWrite, credsIssuerConfig), // make_unique>>(Id, "number-of-primaries", 0, UINT8_MAX, Attributes::NumberOfPrimaries::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -23777,8 +23778,9 @@ void registerClusterColorControl(Commands & commands, CredentialIssuerCommands * WriteCommandType::kWrite, credsIssuerConfig), // make_unique>(Id, "enhanced-current-hue", 0, UINT16_MAX, Attributes::EnhancedCurrentHue::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "enhanced-color-mode", 0, UINT8_MAX, Attributes::EnhancedColorMode::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>( + Id, "enhanced-color-mode", 0, UINT8_MAX, Attributes::EnhancedColorMode::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // make_unique>(Id, "color-loop-active", 0, UINT8_MAX, Attributes::ColorLoopActive::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "color-loop-direction", 0, UINT8_MAX, Attributes::ColorLoopDirection::Id, @@ -23791,8 +23793,9 @@ void registerClusterColorControl(Commands & commands, CredentialIssuerCommands * make_unique>(Id, "color-loop-stored-enhanced-hue", 0, UINT16_MAX, Attributes::ColorLoopStoredEnhancedHue::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "color-capabilities", 0, UINT16_MAX, Attributes::ColorCapabilities::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "color-capabilities", 0, UINT16_MAX, Attributes::ColorCapabilities::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // make_unique>(Id, "color-temp-physical-min-mireds", 0, UINT16_MAX, Attributes::ColorTempPhysicalMinMireds::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index aa122cb62da046..12382e3cb41495 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -15550,7 +15550,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("CurrentY", 1, value); } case ColorControl::Attributes::DriftCompensation::Id: { - uint8_t value; + chip::app::Clusters::ColorControl::DriftCompensationEnum value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("DriftCompensation", 1, value); } @@ -15565,12 +15565,12 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("ColorTemperatureMireds", 1, value); } case ColorControl::Attributes::ColorMode::Id: { - uint8_t value; + chip::app::Clusters::ColorControl::ColorModeEnum value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("ColorMode", 1, value); } case ColorControl::Attributes::Options::Id: { - uint8_t value; + chip::BitMask value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("Options", 1, value); } @@ -15730,7 +15730,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("EnhancedCurrentHue", 1, value); } case ColorControl::Attributes::EnhancedColorMode::Id: { - uint8_t value; + chip::app::Clusters::ColorControl::EnhancedColorModeEnum value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("EnhancedColorMode", 1, value); } @@ -15760,7 +15760,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("ColorLoopStoredEnhancedHue", 1, value); } case ColorControl::Attributes::ColorCapabilities::Id: { - uint16_t value; + chip::BitMask value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("ColorCapabilities", 1, value); } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index a61f2a6fa6b27e..dc438df840c885 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -107995,7 +107995,11 @@ class ThermostatSetActivePresetRequest : public ClusterCommand { __auto_type * params = [[MTRThermostatClusterSetActivePresetRequestParams alloc] init]; params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; #if MTR_ENABLE_PROVISIONAL - params.presetHandle = [NSData dataWithBytes:mRequest.presetHandle.data() length:mRequest.presetHandle.size()]; + if (mRequest.presetHandle.IsNull()) { + params.presetHandle = nil; + } else { + params.presetHandle = [NSData dataWithBytes:mRequest.presetHandle.Value().data() length:mRequest.presetHandle.Value().size()]; + } #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; @@ -117680,8 +117684,8 @@ class ColorControlMoveToHue : public ClusterCommand { params.hue = [NSNumber numberWithUnsignedChar:mRequest.hue]; params.direction = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.direction)]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -117733,8 +117737,8 @@ class ColorControlMoveHue : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.moveMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.moveMode)]; params.rate = [NSNumber numberWithUnsignedChar:mRequest.rate]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -117788,8 +117792,8 @@ class ColorControlStepHue : public ClusterCommand { params.stepMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.stepMode)]; params.stepSize = [NSNumber numberWithUnsignedChar:mRequest.stepSize]; params.transitionTime = [NSNumber numberWithUnsignedChar:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -117841,8 +117845,8 @@ class ColorControlMoveToSaturation : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.saturation = [NSNumber numberWithUnsignedChar:mRequest.saturation]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -117894,8 +117898,8 @@ class ColorControlMoveSaturation : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.moveMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.moveMode)]; params.rate = [NSNumber numberWithUnsignedChar:mRequest.rate]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -117949,8 +117953,8 @@ class ColorControlStepSaturation : public ClusterCommand { params.stepMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.stepMode)]; params.stepSize = [NSNumber numberWithUnsignedChar:mRequest.stepSize]; params.transitionTime = [NSNumber numberWithUnsignedChar:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118004,8 +118008,8 @@ class ColorControlMoveToHueAndSaturation : public ClusterCommand { params.hue = [NSNumber numberWithUnsignedChar:mRequest.hue]; params.saturation = [NSNumber numberWithUnsignedChar:mRequest.saturation]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118059,8 +118063,8 @@ class ColorControlMoveToColor : public ClusterCommand { params.colorX = [NSNumber numberWithUnsignedShort:mRequest.colorX]; params.colorY = [NSNumber numberWithUnsignedShort:mRequest.colorY]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118112,8 +118116,8 @@ class ColorControlMoveColor : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.rateX = [NSNumber numberWithShort:mRequest.rateX]; params.rateY = [NSNumber numberWithShort:mRequest.rateY]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118167,8 +118171,8 @@ class ColorControlStepColor : public ClusterCommand { params.stepX = [NSNumber numberWithShort:mRequest.stepX]; params.stepY = [NSNumber numberWithShort:mRequest.stepY]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118220,8 +118224,8 @@ class ColorControlMoveToColorTemperature : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.colorTemperatureMireds = [NSNumber numberWithUnsignedShort:mRequest.colorTemperatureMireds]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118275,8 +118279,8 @@ class ColorControlEnhancedMoveToHue : public ClusterCommand { params.enhancedHue = [NSNumber numberWithUnsignedShort:mRequest.enhancedHue]; params.direction = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.direction)]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118328,8 +118332,8 @@ class ColorControlEnhancedMoveHue : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.moveMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.moveMode)]; params.rate = [NSNumber numberWithUnsignedShort:mRequest.rate]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118383,8 +118387,8 @@ class ColorControlEnhancedStepHue : public ClusterCommand { params.stepMode = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.stepMode)]; params.stepSize = [NSNumber numberWithUnsignedShort:mRequest.stepSize]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118438,8 +118442,8 @@ class ColorControlEnhancedMoveToHueAndSaturation : public ClusterCommand { params.enhancedHue = [NSNumber numberWithUnsignedShort:mRequest.enhancedHue]; params.saturation = [NSNumber numberWithUnsignedChar:mRequest.saturation]; params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118497,8 +118501,8 @@ class ColorControlColorLoopSet : public ClusterCommand { params.direction = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.direction)]; params.time = [NSNumber numberWithUnsignedShort:mRequest.time]; params.startHue = [NSNumber numberWithUnsignedShort:mRequest.startHue]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118546,8 +118550,8 @@ class ColorControlStopMoveStep : public ClusterCommand { __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; __auto_type * params = [[MTRColorControlClusterStopMoveStepParams alloc] init]; params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118603,8 +118607,8 @@ class ColorControlMoveColorTemperature : public ClusterCommand { params.rate = [NSNumber numberWithUnsignedShort:mRequest.rate]; params.colorTemperatureMinimumMireds = [NSNumber numberWithUnsignedShort:mRequest.colorTemperatureMinimumMireds]; params.colorTemperatureMaximumMireds = [NSNumber numberWithUnsignedShort:mRequest.colorTemperatureMaximumMireds]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -118662,8 +118666,8 @@ class ColorControlStepColorTemperature : public ClusterCommand { params.transitionTime = [NSNumber numberWithUnsignedShort:mRequest.transitionTime]; params.colorTemperatureMinimumMireds = [NSNumber numberWithUnsignedShort:mRequest.colorTemperatureMinimumMireds]; params.colorTemperatureMaximumMireds = [NSNumber numberWithUnsignedShort:mRequest.colorTemperatureMaximumMireds]; - params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask]; - params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride]; + params.optionsMask = [NSNumber numberWithUnsignedChar:mRequest.optionsMask.Raw()]; + params.optionsOverride = [NSNumber numberWithUnsignedChar:mRequest.optionsOverride.Raw()]; uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) {