From 9d4d762ce3bbfd1c99aa3dc1a9d488f5e127a581 Mon Sep 17 00:00:00 2001 From: pcoleman Date: Wed, 5 Jun 2024 17:59:16 +0100 Subject: [PATCH 1/6] Update device-energy-management-cluster.xml based on latest cluster spec and regenerate zap files --- .../all-clusters-app.matter | 39 ++- .../energy-management-app.matter | 39 ++- .../DeviceEnergyManagementDelegateImpl.h | 1 + .../DeviceEnergyManagementDelegateImpl.cpp | 5 + ...eEnergyManagementTestEventTriggerHandler.h | 96 ++++++ .../device-energy-management-server.cpp | 273 +++++++++++++-- .../device-energy-management-server.h | 48 +-- .../chip/device-energy-management-cluster.xml | 166 ++++----- .../data_model/controller-clusters.matter | 39 ++- .../chip/devicecontroller/ChipClusters.java | 18 +- .../chip/devicecontroller/ChipStructs.java | 319 +++++++++++------- .../devicecontroller/ClusterIDMapping.java | 2 +- .../devicecontroller/ClusterInfoMapping.java | 12 +- .../devicecontroller/ClusterReadMapping.java | 11 - .../chip/devicecontroller/cluster/files.gni | 1 + ...ceEnergyManagementClusterForecastStruct.kt | 24 +- ...ementClusterPowerAdjustCapabilityStruct.kt | 83 +++++ ...gyManagementClusterSlotAdjustmentStruct.kt | 15 +- ...DeviceEnergyManagementClusterSlotStruct.kt | 20 +- .../clusters/DeviceEnergyManagementCluster.kt | 38 +-- .../java/matter/controller/cluster/files.gni | 1 + ...ceEnergyManagementClusterForecastStruct.kt | 24 +- ...ementClusterPowerAdjustCapabilityStruct.kt | 83 +++++ ...gyManagementClusterSlotAdjustmentStruct.kt | 15 +- ...DeviceEnergyManagementClusterSlotStruct.kt | 20 +- .../CHIPAttributeTLVValueDecoder.cpp | 209 +++++++----- .../python/chip/clusters/CHIPClusters.py | 2 +- .../python/chip/clusters/Objects.py | 85 +++-- .../MTRAttributeTLVValueDecoder.mm | 54 +-- .../CHIP/zap-generated/MTRBaseClusters.h | 12 +- .../CHIP/zap-generated/MTRBaseClusters.mm | 6 +- .../zap-generated/MTRCommandPayloadsObjc.h | 2 +- .../zap-generated/MTRCommandPayloadsObjc.mm | 13 +- .../CHIP/zap-generated/MTRStructsObjc.h | 30 +- .../CHIP/zap-generated/MTRStructsObjc.mm | 120 ++++--- .../zap-generated/cluster-enums-check.h | 13 + .../app-common/zap-generated/cluster-enums.h | 13 + .../zap-generated/cluster-objects.cpp | 167 +++++---- .../zap-generated/cluster-objects.h | 126 ++++--- .../zap-generated/cluster/Commands.h | 4 +- .../cluster/ComplexArgumentParser.cpp | 166 +++++---- .../cluster/ComplexArgumentParser.h | 16 +- .../cluster/logging/DataModelLogger.cpp | 126 ++++--- .../cluster/logging/DataModelLogger.h | 10 +- .../zap-generated/cluster/Commands.h | 14 +- 45 files changed, 1724 insertions(+), 856 deletions(-) create mode 100644 src/app/clusters/device-energy-management-server/DeviceEnergyManagementTestEventTriggerHandler.h create mode 100644 src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt create mode 100644 src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt 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 804d1eae5fbd32..a9443038aa3c9e 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 @@ -4069,7 +4069,7 @@ cluster ElectricalEnergyMeasurement = 145 { /** This cluster allows a client to manage the power draw of a device. An example of such a client could be an Energy Management System (EMS) which controls an Energy Smart Appliance (ESA). */ provisional cluster DeviceEnergyManagement = 152 { - revision 3; + revision 4; enum AdjustmentCauseEnum : enum8 { kLocalOptimization = 0; @@ -4130,6 +4130,12 @@ provisional cluster DeviceEnergyManagement = 152 { kOptOut = 3; } + enum PowerAdjustReasonEnum : enum8 { + kNoAdjustment = 0; + kLocalOptimizationAdjustment = 1; + kGridOptimizationAdjustment = 2; + } + bitmap Feature : bitmap32 { kPowerAdjustment = 0x1; kPowerForecastReporting = 0x2; @@ -4147,13 +4153,25 @@ provisional cluster DeviceEnergyManagement = 152 { optional int16u currency = 3; } + struct PowerAdjustStruct { + power_mw minPower = 0; + power_mw maxPower = 1; + elapsed_s minDuration = 2; + elapsed_s maxDuration = 3; + } + + struct PowerAdjustCapabilityStruct { + nullable PowerAdjustStruct powerAdjustCapability[] = 0; + PowerAdjustReasonEnum cause = 1; + } + struct SlotStruct { elapsed_s minDuration = 0; elapsed_s maxDuration = 1; elapsed_s defaultDuration = 2; elapsed_s elapsedSlotTime = 3; elapsed_s remainingSlotTime = 4; - optional boolean slotIsPauseable = 5; + optional boolean slotIsPausable = 5; optional elapsed_s minPauseDuration = 6; optional elapsed_s maxPauseDuration = 7; optional int16u manufacturerESAState = 8; @@ -4169,13 +4187,13 @@ provisional cluster DeviceEnergyManagement = 152 { } struct ForecastStruct { - int16u forecastId = 0; + int32u forecastID = 0; nullable int16u activeSlotNumber = 1; epoch_s startTime = 2; epoch_s endTime = 3; optional nullable epoch_s earliestStartTime = 4; optional epoch_s latestEndTime = 5; - boolean isPauseable = 6; + boolean isPausable = 6; SlotStruct slots[] = 7; ForecastUpdateReasonEnum forecastUpdateReason = 8; } @@ -4188,16 +4206,9 @@ provisional cluster DeviceEnergyManagement = 152 { optional int8s loadControl = 4; } - struct PowerAdjustStruct { - power_mw minPower = 0; - power_mw maxPower = 1; - elapsed_s minDuration = 2; - elapsed_s maxDuration = 3; - } - struct SlotAdjustmentStruct { int8u slotIndex = 0; - power_mw nominalPower = 1; + optional power_mw nominalPower = 1; elapsed_s duration = 2; } @@ -4222,7 +4233,7 @@ provisional cluster DeviceEnergyManagement = 152 { readonly attribute ESAStateEnum ESAState = 2; readonly attribute power_mw absMinPower = 3; readonly attribute power_mw absMaxPower = 4; - readonly attribute optional nullable PowerAdjustStruct powerAdjustmentCapability[] = 5; + readonly attribute optional nullable PowerAdjustCapabilityStruct powerAdjustmentCapability = 5; readonly attribute optional nullable ForecastStruct forecast = 6; readonly attribute optional OptOutStateEnum optOutState = 7; readonly attribute command_id generatedCommandList[] = 65528; @@ -4249,7 +4260,7 @@ provisional cluster DeviceEnergyManagement = 152 { } request struct ModifyForecastRequestRequest { - int32u forecastId = 0; + int32u forecastID = 0; SlotAdjustmentStruct slotAdjustments[] = 1; AdjustmentCauseEnum cause = 2; } diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.matter b/examples/energy-management-app/energy-management-common/energy-management-app.matter index 68db2eea271ec3..54059e32fc4588 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.matter +++ b/examples/energy-management-app/energy-management-common/energy-management-app.matter @@ -1430,7 +1430,7 @@ cluster ElectricalEnergyMeasurement = 145 { /** This cluster allows a client to manage the power draw of a device. An example of such a client could be an Energy Management System (EMS) which controls an Energy Smart Appliance (ESA). */ provisional cluster DeviceEnergyManagement = 152 { - revision 3; + revision 4; enum AdjustmentCauseEnum : enum8 { kLocalOptimization = 0; @@ -1491,6 +1491,12 @@ provisional cluster DeviceEnergyManagement = 152 { kOptOut = 3; } + enum PowerAdjustReasonEnum : enum8 { + kNoAdjustment = 0; + kLocalOptimizationAdjustment = 1; + kGridOptimizationAdjustment = 2; + } + bitmap Feature : bitmap32 { kPowerAdjustment = 0x1; kPowerForecastReporting = 0x2; @@ -1508,13 +1514,25 @@ provisional cluster DeviceEnergyManagement = 152 { optional int16u currency = 3; } + struct PowerAdjustStruct { + power_mw minPower = 0; + power_mw maxPower = 1; + elapsed_s minDuration = 2; + elapsed_s maxDuration = 3; + } + + struct PowerAdjustCapabilityStruct { + nullable PowerAdjustStruct powerAdjustCapability[] = 0; + PowerAdjustReasonEnum cause = 1; + } + struct SlotStruct { elapsed_s minDuration = 0; elapsed_s maxDuration = 1; elapsed_s defaultDuration = 2; elapsed_s elapsedSlotTime = 3; elapsed_s remainingSlotTime = 4; - optional boolean slotIsPauseable = 5; + optional boolean slotIsPausable = 5; optional elapsed_s minPauseDuration = 6; optional elapsed_s maxPauseDuration = 7; optional int16u manufacturerESAState = 8; @@ -1530,13 +1548,13 @@ provisional cluster DeviceEnergyManagement = 152 { } struct ForecastStruct { - int16u forecastId = 0; + int32u forecastID = 0; nullable int16u activeSlotNumber = 1; epoch_s startTime = 2; epoch_s endTime = 3; optional nullable epoch_s earliestStartTime = 4; optional epoch_s latestEndTime = 5; - boolean isPauseable = 6; + boolean isPausable = 6; SlotStruct slots[] = 7; ForecastUpdateReasonEnum forecastUpdateReason = 8; } @@ -1549,16 +1567,9 @@ provisional cluster DeviceEnergyManagement = 152 { optional int8s loadControl = 4; } - struct PowerAdjustStruct { - power_mw minPower = 0; - power_mw maxPower = 1; - elapsed_s minDuration = 2; - elapsed_s maxDuration = 3; - } - struct SlotAdjustmentStruct { int8u slotIndex = 0; - power_mw nominalPower = 1; + optional power_mw nominalPower = 1; elapsed_s duration = 2; } @@ -1583,7 +1594,7 @@ provisional cluster DeviceEnergyManagement = 152 { readonly attribute ESAStateEnum ESAState = 2; readonly attribute power_mw absMinPower = 3; readonly attribute power_mw absMaxPower = 4; - readonly attribute optional nullable PowerAdjustStruct powerAdjustmentCapability[] = 5; + readonly attribute optional nullable PowerAdjustCapabilityStruct powerAdjustmentCapability = 5; readonly attribute optional nullable ForecastStruct forecast = 6; readonly attribute optional OptOutStateEnum optOutState = 7; readonly attribute command_id generatedCommandList[] = 65528; @@ -1610,7 +1621,7 @@ provisional cluster DeviceEnergyManagement = 152 { } request struct ModifyForecastRequestRequest { - int32u forecastId = 0; + int32u forecastID = 0; SlotAdjustmentStruct slotAdjustments[] = 1; AdjustmentCauseEnum cause = 2; } diff --git a/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h b/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h index a61be0f3c1770c..1248fc405a3c8a 100644 --- a/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h +++ b/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h @@ -69,6 +69,7 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate virtual CHIP_ERROR SetAbsMaxPower(int64_t) override; virtual CHIP_ERROR SetPowerAdjustmentCapability(Attributes::PowerAdjustmentCapability::TypeInfo::Type) override; virtual CHIP_ERROR SetForecast(DataModel::Nullable) override; + virtual CHIP_ERROR SetOptOutState(OptOutStateEnum) override; private: ESATypeEnum mEsaType; diff --git a/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp b/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp index c918d3a729d3a4..8f122bdac2b046 100644 --- a/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp +++ b/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp @@ -364,3 +364,8 @@ CHIP_ERROR DeviceEnergyManagementDelegate::SetForecast(DataModel::Nullable +#include + +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @retval true on success + * @retval false if error happened + */ +bool HandleDeviceEnergyManagementTestEventTrigger(uint64_t eventTrigger); + +namespace chip { + +/* + * These Test EventTrigger values can be used to produce artificial DEM forecasts + * + * They are sent along with the enableKey (manufacturer defined secret) + * in the General Diagnostic cluster TestEventTrigger command + */ +enum class DeviceEnergyManagementTrigger : uint64_t +{ + // Simulate a fixed forecast power usage including one or more PowerAdjustmentStructs + kPowerAdjustment = 0x0098'0000'0000'0000, + // Clear the PowerAdjustment structs + kPowerAdjustmentClear = 0x0098'0000'0000'0001, + // Simulate user opt-out of Local Optimization + kUserOptOutLocalOptimization = 0x0098'0000'0000'0002, + // Simulate user opt-out of Grid Optimization + kUserOptOutGridOptimization = 0x0098'0000'0000'0003, + // Remove all user opt-out opting out + kUserOptOutClearAll = 0x0098'0000'0000'0004, + // Simulate a fixed forecast with EarliestStartTime earlier than startTime, and LatestEndTime greater than EndTime + kStartTimeAdjustment = 0x0098'0000'0000'0005, + // Clear the StartTimeAdjustment simulated forecast + kStartTimeAdjustmentClear = 0x0098'0000'0000'0006, + // Simulate a fixed forecast with one pausable slo with MinPauseDuration >1, MaxPauseDuration>1 and one non pausable slot + kPausable = 0x0098'0000'0000'0007, + // Simulate a moving time to the next forecast slot + kPausableNextSlot = 0x0098'0000'0000'0008, + // Clear the Pausable simulated forecast + kPausableClear = 0x0098'0000'0000'0009, + // Simulate a forecast power usage with at least 2 and at most 4 slots + kForecastAdjustment = 0x0098'0000'0000'000A, + // Simulate moving time to the next forecast slot + kForecastAdjustmentNextSlot = 0x0098'0000'0000'000B, + // Clear the forecast adjustment + kForecastAdjustmentClear = 0x0098'0000'0000'000C, + // Simulate a forecast power usage with at least 2 and at most 4 slots + kConstraintBasedAdjustment = 0x0098'0000'0000'000D, + // Clear the constraint based adjustment + kConstraintBasedAdjustmentClear = 0x0098'0000'0000'000E, + // Simulate a forecast with at least 1 slot + kForecast = 0x0098'0000'0000'000F, + // Clear the forecast + kForecastClear = 0x0098'0000'0000'0010, +}; + +class DeviceEnergyManagementTestEventTriggerHandler : public TestEventTriggerHandler +{ +public: + DeviceEnergyManagementTestEventTriggerHandler() {} + + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override + { + if (HandleDeviceEnergyManagementTestEventTrigger(eventTrigger)) + { + return CHIP_NO_ERROR; + } + return CHIP_ERROR_INVALID_ARGUMENT; + } +}; + +} // namespace chip diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp index da1fd23d151987..2b42c74369cdcd 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp @@ -276,7 +276,7 @@ Status Instance::CheckOptOutAllowsRequest(AdjustmentCauseEnum adjustmentCause) return Status::Success; case AdjustmentCauseEnum::kLocalOptimization: default: - return Status::Failure; + return Status::ConstraintError; } case OptOutStateEnum::kGridOptOut: /* User has opted out from Grid only */ @@ -287,12 +287,12 @@ Status Instance::CheckOptOutAllowsRequest(AdjustmentCauseEnum adjustmentCause) return Status::Success; case AdjustmentCauseEnum::kGridOptimization: default: - return Status::Failure; + return Status::ConstraintError; } case OptOutStateEnum::kOptOut: /* User has opted out from both local and grid */ ChipLogProgress(Zcl, "DEM: OptOutState = kOptOut"); - return Status::Failure; + return Status::ConstraintError; default: ChipLogError(Zcl, "DEM: invalid optOutState %d", static_cast(optOutState)); @@ -302,15 +302,21 @@ Status Instance::CheckOptOutAllowsRequest(AdjustmentCauseEnum adjustmentCause) void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::PowerAdjustRequest::DecodableType & commandData) { - Status status; bool validArgs = false; - PowerAdjustmentCapability::TypeInfo::Type powerAdjustmentCapability; int64_t power = commandData.power; uint32_t durationSec = commandData.duration; AdjustmentCauseEnum adjustmentCause = commandData.cause; - status = CheckOptOutAllowsRequest(adjustmentCause); + // Notify the appliance if the appliance hardware cannot be adjusted, then return Failure + if (!HasFeature(DeviceEnergyManagement::Feature::kPowerAdjustment)) + { + ChipLogError(Zcl, "PowerAdjust not supported"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } + + Status status = CheckOptOutAllowsRequest(adjustmentCause); if (status != Status::Success) { ChipLogError(Zcl, "DEM: PowerAdjustRequest command rejected"); @@ -318,16 +324,23 @@ void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::Po return; } - powerAdjustmentCapability = mDelegate.GetPowerAdjustmentCapability(); - if (powerAdjustmentCapability.IsNull()) + DataModel::Nullable powerAdjustmentCapabilityStruct = mDelegate.GetPowerAdjustmentCapability(); + if (powerAdjustmentCapabilityStruct.IsNull()) + { + ChipLogError(Zcl, "DEM: powerAdjustmentCapabilityStruct IsNull"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + if (powerAdjustmentCapabilityStruct.Value().powerAdjustCapability.IsNull()) { - ChipLogError(Zcl, "DEM: powerAdjustmentCapability IsNull"); + ChipLogError(Zcl, "DEM: powerAdjustmentCapabilityStruct.powerAdjustCapability IsNull"); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); return; } /* PowerAdjustmentCapability is a list - so iterate through checking if the command is within one of the offers */ - for (auto pas : powerAdjustmentCapability.Value()) + for (auto pas : powerAdjustmentCapabilityStruct.Value().powerAdjustCapability.Value()) { if ((power >= pas.minPower) && (durationSec >= pas.minDuration) && (power <= pas.maxPower) && (durationSec <= pas.maxDuration)) @@ -358,18 +371,23 @@ void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::Po void Instance::HandleCancelPowerAdjustRequest(HandlerContext & ctx, const Commands::CancelPowerAdjustRequest::DecodableType & commandData) { - Status status; + if (!HasFeature(DeviceEnergyManagement::Feature::kPowerAdjustment)) + { + ChipLogError(Zcl, "PowerAdjust not supported"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } /* Check that the ESA state is PowerAdjustActive */ ESAStateEnum esaStatus = mDelegate.GetESAState(); if (ESAStateEnum::kPowerAdjustActive != esaStatus) { ChipLogError(Zcl, "DEM: kPowerAdjustActive != esaStatus"); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidInState); return; } - status = mDelegate.CancelPowerAdjustRequest(); + Status status = mDelegate.CancelPowerAdjustRequest(); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { @@ -492,6 +510,13 @@ void Instance::HandlePauseRequest(HandlerContext & ctx, const Commands::PauseReq CHIP_ERROR err = CHIP_NO_ERROR; DataModel::Nullable forecast = mDelegate.GetForecast(); + if (!HasFeature(DeviceEnergyManagement::Feature::kPausable)) + { + ChipLogError(AppServer, "Pause not supported"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } + uint32_t duration = commandData.duration; AdjustmentCauseEnum adjustmentCause = commandData.cause; @@ -530,10 +555,10 @@ void Instance::HandlePauseRequest(HandlerContext & ctx, const Commands::PauseReq return; } - /* We expect that there should be a slotIsPauseable entry (but it is optional) */ - if (!forecast.Value().slots[activeSlotNumber].slotIsPauseable.HasValue()) + /* We expect that there should be a slotIsPausable entry (but it is optional) */ + if (!forecast.Value().slots[activeSlotNumber].slotIsPausable.HasValue()) { - ChipLogError(Zcl, "DEM: activeSlotNumber %d does not include slotIsPauseable.", activeSlotNumber); + ChipLogError(Zcl, "DEM: activeSlotNumber %d does not include slotIsPausable.", activeSlotNumber); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); return; } @@ -552,14 +577,14 @@ void Instance::HandlePauseRequest(HandlerContext & ctx, const Commands::PauseReq return; } - if (!forecast.Value().slots[activeSlotNumber].slotIsPauseable.Value()) + if (!forecast.Value().slots[activeSlotNumber].slotIsPausable.Value()) { - ChipLogError(Zcl, "DEM: activeSlotNumber %d is NOT pauseable.", activeSlotNumber); + ChipLogError(Zcl, "DEM: activeSlotNumber %d is NOT pausable.", activeSlotNumber); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); return; } - if ((duration < forecast.Value().slots[activeSlotNumber].minPauseDuration.Value()) && + if ((duration < forecast.Value().slots[activeSlotNumber].minPauseDuration.Value()) || (duration > forecast.Value().slots[activeSlotNumber].maxPauseDuration.Value())) { ChipLogError(Zcl, "DEM: out of range pause duration %ld", static_cast(duration)); @@ -586,7 +611,12 @@ void Instance::HandlePauseRequest(HandlerContext & ctx, const Commands::PauseReq void Instance::HandleResumeRequest(HandlerContext & ctx, const Commands::ResumeRequest::DecodableType & commandData) { - Status status; + if (!HasFeature(DeviceEnergyManagement::Feature::kPausable)) + { + ChipLogError(AppServer, "Pause not supported"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } if (ESAStateEnum::kPaused != mDelegate.GetESAState()) { @@ -595,7 +625,7 @@ void Instance::HandleResumeRequest(HandlerContext & ctx, const Commands::ResumeR return; } - status = mDelegate.ResumeRequest(); + Status status = mDelegate.ResumeRequest(); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { @@ -606,10 +636,17 @@ void Instance::HandleResumeRequest(HandlerContext & ctx, const Commands::ResumeR void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands::ModifyForecastRequest::DecodableType & commandData) { + if (!HasFeature(DeviceEnergyManagement::Feature::kForecastAdjustment)) + { + ChipLogError(Zcl, "ModifyForecast not supported"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } + Status status; DataModel::Nullable forecast; - uint32_t forecastId = commandData.forecastId; + uint32_t forecastID = commandData.forecastID; DataModel::DecodableList slotAdjustments = commandData.slotAdjustments; AdjustmentCauseEnum adjustmentCause = commandData.cause; @@ -629,7 +666,56 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: return; } - status = mDelegate.ModifyForecastRequest(forecastId, slotAdjustments, adjustmentCause); + // Check the various values in the slot structures + auto iterator = slotAdjustments.begin(); + while (iterator.Next()) + { + const Structs::SlotAdjustmentStruct::Type & slotAdjustment = iterator.GetValue(); + + // Check for an invalid slotIndex + if (slotAdjustment.slotIndex > forecast.Value().slots.size()) + { + ChipLogError(Zcl, "DEM: Bad slot index %d", slotAdjustment.slotIndex); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + // Check to see if trying to modify a slot which have already been run + if (!forecast.Value().activeSlotNumber.IsNull() && slotAdjustment.slotIndex < forecast.Value().activeSlotNumber.Value()) + { + ChipLogError(Zcl, "DEM: Modifying already run slot index %d", slotAdjustment.slotIndex); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + const Structs::SlotStruct::Type & slot = forecast.Value().slots[slotAdjustment.slotIndex]; + + // NominalPower is only relevant if PFR is supported + if (HasFeature(Feature::kPowerForecastReporting)) + { + if (!slot.minPowerAdjustment.HasValue() || + !slot.maxPowerAdjustment.HasValue() || + slotAdjustment.nominalPower.Value() < slot.minPowerAdjustment.Value() || + slotAdjustment.nominalPower.Value() > slot.maxPowerAdjustment.Value()) + { + ChipLogError(Zcl, "DEM: Bad nominalPower"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + } + + if (!slot.minDurationAdjustment.HasValue() || + !slot.maxDurationAdjustment.HasValue() || + slotAdjustment.duration < slot.minDurationAdjustment.Value() || + slotAdjustment.duration > slot.maxDurationAdjustment.Value()) + { + ChipLogError(Zcl, "DEM: Bad min/max duration"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + } + + status = mDelegate.ModifyForecastRequest(forecastID, slotAdjustments, adjustmentCause); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { @@ -641,7 +727,14 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, const Commands::RequestConstraintBasedForecast::DecodableType & commandData) { - Status status; + if (!HasFeature(DeviceEnergyManagement::Feature::kConstraintBasedAdjustment)) + { + ChipLogError(AppServer, "RequestConstraintBasedForecast CON not supported"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } + + Status status = Status::Success; DataModel::DecodableList constraints = commandData.constraints; AdjustmentCauseEnum adjustmentCause = commandData.cause; @@ -654,6 +747,96 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, return; } + uint32_t currentUtcTime = 0; + status = GetCurrentUtcTime(currentUtcTime); + if (status != Status::Success) + { + ChipLogError(Zcl, "DEM: Forecast is Null"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); + return; + } + + // Check for invalid power levels and whether the constraint time/duration is in the past + { + auto iterator = constraints.begin(); + if (iterator.Next()) + { + const Structs::ConstraintsStruct::DecodableType & constraint = iterator.GetValue(); + + // Check to see if this constraint is in the past + if (constraint.startTime < currentUtcTime) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + if (HasFeature(Feature::kPowerForecastReporting)) + { + if (!constraint.nominalPower.HasValue()) + { + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast no nominalPower"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidCommand); + return; + } + + if (constraint.nominalPower.Value() < mDelegate.GetAbsMinPower() || + constraint.nominalPower.Value() > mDelegate.GetAbsMaxPower()) + { + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast nominalPower out of range [absMinPower, absMaxPower]"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + if (!constraint.maximumEnergy.HasValue()) + { + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast no value for maximumEnergy"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidCommand); + return; + } + } + + if (HasFeature(Feature::kStateForecastReporting)) + { + if (!constraint.loadControl.HasValue()) + { + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast no loadControl"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidCommand); + return; + } + + if (constraint.loadControl.Value() < -100 || constraint.loadControl.Value() > 100) + { + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast bad loadControl %d", constraint.loadControl.HasValue()); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + } + } + } + + // Check for overlappping elements + { + auto iterator = constraints.begin(); + if (iterator.Next()) + { + // Get the first constraint + const Structs::ConstraintsStruct::DecodableType & prevConstraint = iterator.GetValue(); + + // Start comparing next vs prev constraints + while (iterator.Next()) + { + const Structs::ConstraintsStruct::DecodableType & constraint = iterator.GetValue(); + if (constraint.startTime < prevConstraint.startTime || + prevConstraint.startTime + prevConstraint.duration >= constraint.startTime) + { + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast overlapping constraint times"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + } + } + } + status = mDelegate.RequestConstraintBasedForecast(constraints, adjustmentCause); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) @@ -665,15 +848,47 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, void Instance::HandleCancelRequest(HandlerContext & ctx, const Commands::CancelRequest::DecodableType & commandData) { - Status status; + Status status = Status::Failure; + DataModel::Nullable forecast = mDelegate.GetForecast(); + + if (forecast.IsNull()) + { + ChipLogDetail(AppServer, "Cancelling on a Null forecast!"); + status = Status::Failure; + } + else if (forecast.Value().forecastUpdateReason == ForecastUpdateReasonEnum::kInternalOptimization) + { + ChipLogDetail(AppServer, "Bad Cancel when ESA ForecastUpdateReason was already Internal Optimization!"); + status = Status::InvalidInState; + } + else + { + status = mDelegate.CancelRequest(); + } - status = mDelegate.CancelRequest(); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); - if (status != Status::Success) +} + +Status Instance::GetCurrentUtcTime(uint32_t & currentUtcTime) const +{ + currentUtcTime = 0; + System::Clock::Milliseconds64 cTMs; + + CHIP_ERROR err = System::SystemClock().GetClock_RealTimeMS(cTMs); + if (err != CHIP_NO_ERROR) { - ChipLogError(Zcl, "DEM: CancelRequest FAILURE"); - return; + ChipLogError(Zcl, "DEM: Unable to get current time - err:%" CHIP_ERROR_FORMAT, err.Format()); + return Status::Failure; + } + + auto unixEpoch = std::chrono::duration_cast(cTMs).count(); + if (!UnixEpochToChipEpochTime(unixEpoch, currentUtcTime)) + { + ChipLogError(Zcl, "DEM: unable to convert Unix Epoch time to Matter Epoch Time"); + return Status::Failure; } + + return Status::Success; } } // namespace DeviceEnergyManagement diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.h b/src/app/clusters/device-energy-management-server/device-energy-management-server.h index 2f09dad1fee85e..7557871f48c3dd 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.h +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.h @@ -61,7 +61,7 @@ class Delegate virtual Protocols::InteractionModel::Status CancelPowerAdjustRequest() = 0; /** - * @brief Delegate for the ESA SHALL update its Forecast attribute with the RequestedStartTime including a new ForecastId. + * @brief Delegate for the ESA SHALL update its Forecast attribute with the RequestedStartTime including a new ForecastID. * * If the ESA supports ForecastAdjustment, and the ESAState is not UserOptOut and the RequestedStartTime is after * the EarliestStartTime and the resulting EndTime is before the LatestEndTime, then ESA SHALL accept the request @@ -71,6 +71,8 @@ class Delegate * * @param requestedStartTime The requested start time in UTC that the client would like the appliance to shift its power * forecast to. + * @param cause Who (Grid/local) is triggering this change. + * * @return Success if the StartTime in the Forecast is updated, otherwise the command SHALL be rejected with appropriate * IM_Status. */ @@ -109,16 +111,16 @@ class Delegate * If the ESA supports FA, and the ESAState is not UserOptOut it SHALL attempt to adjust its power forecast. * This allows a one or more modifications in a single command by sending a list of modifications (one for each 'slot'). * Attempts to modify slots which have already past, SHALL result in the entire command being rejected. - * If the ESA accepts the requested Forecast then it SHALL update its Forecast attribute (incrementing its ForecastId) + * If the ESA accepts the requested Forecast then it SHALL update its Forecast attribute (incrementing its ForecastID) * and run the revised Forecast as its new intended operation. * - * @param forecastId Indicates the ESA ForecastId that is to be modified. - * @param slotAdjustments List of adjustments to be applied to the ESA, corresponding to the expected ESA forecastId. + * @param forecastID Indicates the ESA ForecastID that is to be modified. + * @param slotAdjustments List of adjustments to be applied to the ESA, corresponding to the expected ESA forecastID. * @return Success if the entire list of SlotAdjustmentStruct are accepted, otherwise the command * SHALL be rejected returning other IM_Status. */ virtual Protocols::InteractionModel::Status - ModifyForecastRequest(const uint32_t forecastId, + ModifyForecastRequest(const uint32_t forecastID, const DataModel::DecodableList & slotAdjustments, AdjustmentCauseEnum cause) = 0; @@ -128,7 +130,7 @@ class Delegate * The ESA SHALL inspect the requested power limits to ensure that there are no overlapping elements. The ESA * manufacturer may also reject the request if it could cause the user’s preferences to be breached (e.g. may * cause the home to be too hot or too cold, or a battery to be insufficiently charged). - * If the ESA can meet the requested power limits, it SHALL regenerate a new Power Forecast with a new ForecastId. + * If the ESA can meet the requested power limits, it SHALL regenerate a new Power Forecast with a new ForecastID. * * @param constraints Sequence of turn up/down power requests that the ESA is being asked to constrain its operation within. * @return Success if successful, otherwise the command SHALL be rejected returning other IM_Status. @@ -158,24 +160,25 @@ class Delegate // ------------------------------------------------------------------ // Get attribute methods - virtual ESATypeEnum GetESAType() = 0; - virtual bool GetESACanGenerate() = 0; - virtual ESAStateEnum GetESAState() = 0; - virtual int64_t GetAbsMinPower() = 0; - virtual int64_t GetAbsMaxPower() = 0; - virtual Attributes::PowerAdjustmentCapability::TypeInfo::Type GetPowerAdjustmentCapability() = 0; - virtual DataModel::Nullable GetForecast() = 0; - virtual OptOutStateEnum GetOptOutState() = 0; + virtual ESATypeEnum GetESAType() = 0; + virtual bool GetESACanGenerate() = 0; + virtual ESAStateEnum GetESAState() = 0; + virtual int64_t GetAbsMinPower() = 0; + virtual int64_t GetAbsMaxPower() = 0; + virtual DataModel::Nullable GetPowerAdjustmentCapability() = 0; + virtual DataModel::Nullable GetForecast() = 0; + virtual OptOutStateEnum GetOptOutState() = 0; // ------------------------------------------------------------------ // Set attribute methods - virtual CHIP_ERROR SetESAType(ESATypeEnum) = 0; - virtual CHIP_ERROR SetESACanGenerate(bool) = 0; - virtual CHIP_ERROR SetESAState(ESAStateEnum) = 0; - virtual CHIP_ERROR SetAbsMinPower(int64_t) = 0; - virtual CHIP_ERROR SetAbsMaxPower(int64_t) = 0; - virtual CHIP_ERROR SetPowerAdjustmentCapability(Attributes::PowerAdjustmentCapability::TypeInfo::Type) = 0; - virtual CHIP_ERROR SetForecast(DataModel::Nullable) = 0; + virtual CHIP_ERROR SetESAType(ESATypeEnum) = 0; + virtual CHIP_ERROR SetESACanGenerate(bool) = 0; + virtual CHIP_ERROR SetESAState(ESAStateEnum) = 0; + virtual CHIP_ERROR SetAbsMinPower(int64_t) = 0 ; + virtual CHIP_ERROR SetAbsMaxPower(int64_t) = 0; + virtual CHIP_ERROR SetPowerAdjustmentCapability(DataModel::Nullable) = 0; + virtual CHIP_ERROR SetForecast(DataModel::Nullable) = 0; + virtual CHIP_ERROR SetOptOutState(OptOutStateEnum) = 0; protected: EndpointId mEndpointId = 0; @@ -199,6 +202,9 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface bool HasFeature(Feature aFeature) const; +private: + Protocols::InteractionModel::Status GetCurrentUtcTime(uint32_t & currentUtcTime) const; + private: Delegate & mDelegate; BitMask mFeature; diff --git a/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml index 3f921f4e554409..b087f3c162ab8d 100644 --- a/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml @@ -16,8 +16,6 @@ limitations under the License. --> - - Device Energy Management Energy Management @@ -26,139 +24,133 @@ limitations under the License. true true This cluster allows a client to manage the power draw of a device. An example of such a client could be an Energy Management System (EMS) which controls an Energy Smart Appliance (ESA). - - + - +adjustment (within the limits offered by the ESA)."> + +future power consumption vs time."> + + + + + - - - - - - - - - - - + + + + + + - + - - - - - - - - - - - - - - - - +future state vs time."> + + + + + - - + + - - + + - - - - - + + - - - - - + + - - ESAType - ESACanGenerate - ESAState - AbsMinPower - AbsMaxPower + ESAType + ESACanGenerate + ESAState + AbsMinPower + AbsMaxPower - PowerAdjustmentCapability + PowerAdjustmentCapability - Forecast - OptOutState + Forecast + OptOutState Allows a client to request an adjustment in the power consumption of an ESA for a specified duration. - - - + + + + Allows a client to cancel an ongoing PowerAdjustmentRequest operation. + Allows a client to adjust the start time of a Forecast sequence that has not yet started operation (i.e. where the current Forecast StartTime is in the future). - - + + + Allows a client to temporarily pause an operation and reduce the ESAs energy demand. - - + + + Allows a client to cancel the PauseRequest command and enable earlier resumption of operation. + Allows a client to modify a Forecast within the limits allowed by the ESA. - - - + + + + Allows a client to ask the ESA to recompute its Forecast based on power and time constraints. - - + + + Allows a client to request cancellation of a previous adjustment request in a StartTimeAdjustRequest, ModifyForecastRequest or RequestConstraintBasedForecast command + PowerAdjustStart + PowerAdjustEnd + Paused + Resumed + + @@ -225,6 +217,13 @@ limitations under the License. + + + + + + + @@ -233,6 +232,12 @@ limitations under the License. + + + + + + @@ -243,13 +248,13 @@ limitations under the License. - + - + @@ -261,7 +266,7 @@ limitations under the License. - + @@ -279,17 +284,16 @@ limitations under the License. - + - + - diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index ab2e0db009c888..13992dcbf5b079 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -4594,7 +4594,7 @@ provisional cluster Messages = 151 { /** This cluster allows a client to manage the power draw of a device. An example of such a client could be an Energy Management System (EMS) which controls an Energy Smart Appliance (ESA). */ provisional cluster DeviceEnergyManagement = 152 { - revision 3; + revision 4; enum AdjustmentCauseEnum : enum8 { kLocalOptimization = 0; @@ -4655,6 +4655,12 @@ provisional cluster DeviceEnergyManagement = 152 { kOptOut = 3; } + enum PowerAdjustReasonEnum : enum8 { + kNoAdjustment = 0; + kLocalOptimizationAdjustment = 1; + kGridOptimizationAdjustment = 2; + } + bitmap Feature : bitmap32 { kPowerAdjustment = 0x1; kPowerForecastReporting = 0x2; @@ -4672,13 +4678,25 @@ provisional cluster DeviceEnergyManagement = 152 { optional int16u currency = 3; } + struct PowerAdjustStruct { + power_mw minPower = 0; + power_mw maxPower = 1; + elapsed_s minDuration = 2; + elapsed_s maxDuration = 3; + } + + struct PowerAdjustCapabilityStruct { + nullable PowerAdjustStruct powerAdjustCapability[] = 0; + PowerAdjustReasonEnum cause = 1; + } + struct SlotStruct { elapsed_s minDuration = 0; elapsed_s maxDuration = 1; elapsed_s defaultDuration = 2; elapsed_s elapsedSlotTime = 3; elapsed_s remainingSlotTime = 4; - optional boolean slotIsPauseable = 5; + optional boolean slotIsPausable = 5; optional elapsed_s minPauseDuration = 6; optional elapsed_s maxPauseDuration = 7; optional int16u manufacturerESAState = 8; @@ -4694,13 +4712,13 @@ provisional cluster DeviceEnergyManagement = 152 { } struct ForecastStruct { - int16u forecastId = 0; + int32u forecastID = 0; nullable int16u activeSlotNumber = 1; epoch_s startTime = 2; epoch_s endTime = 3; optional nullable epoch_s earliestStartTime = 4; optional epoch_s latestEndTime = 5; - boolean isPauseable = 6; + boolean isPausable = 6; SlotStruct slots[] = 7; ForecastUpdateReasonEnum forecastUpdateReason = 8; } @@ -4713,16 +4731,9 @@ provisional cluster DeviceEnergyManagement = 152 { optional int8s loadControl = 4; } - struct PowerAdjustStruct { - power_mw minPower = 0; - power_mw maxPower = 1; - elapsed_s minDuration = 2; - elapsed_s maxDuration = 3; - } - struct SlotAdjustmentStruct { int8u slotIndex = 0; - power_mw nominalPower = 1; + optional power_mw nominalPower = 1; elapsed_s duration = 2; } @@ -4747,7 +4758,7 @@ provisional cluster DeviceEnergyManagement = 152 { readonly attribute ESAStateEnum ESAState = 2; readonly attribute power_mw absMinPower = 3; readonly attribute power_mw absMaxPower = 4; - readonly attribute optional nullable PowerAdjustStruct powerAdjustmentCapability[] = 5; + readonly attribute optional nullable PowerAdjustCapabilityStruct powerAdjustmentCapability = 5; readonly attribute optional nullable ForecastStruct forecast = 6; readonly attribute optional OptOutStateEnum optOutState = 7; readonly attribute command_id generatedCommandList[] = 65528; @@ -4774,7 +4785,7 @@ provisional cluster DeviceEnergyManagement = 152 { } request struct ModifyForecastRequestRequest { - int32u forecastId = 0; + int32u forecastID = 0; SlotAdjustmentStruct slotAdjustments[] = 1; AdjustmentCauseEnum cause = 2; } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index 7a16c3355daf4f..d0c0e2bda81964 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -31198,17 +31198,17 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, commandArgs, timedInvokeTimeoutMs); } - public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastId, ArrayList slotAdjustments, Integer cause) { - modifyForecastRequest(callback, forecastId, slotAdjustments, cause, 0); + public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastID, ArrayList slotAdjustments, Integer cause) { + modifyForecastRequest(callback, forecastID, slotAdjustments, cause, 0); } - public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastId, ArrayList slotAdjustments, Integer cause, int timedInvokeTimeoutMs) { + public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastID, ArrayList slotAdjustments, Integer cause, int timedInvokeTimeoutMs) { final long commandId = 5L; ArrayList elements = new ArrayList<>(); - final long forecastIdFieldID = 0L; - BaseTLVType forecastIdtlvValue = new UIntType(forecastId); - elements.add(new StructElement(forecastIdFieldID, forecastIdtlvValue)); + final long forecastIDFieldID = 0L; + BaseTLVType forecastIDtlvValue = new UIntType(forecastID); + elements.add(new StructElement(forecastIDFieldID, forecastIDtlvValue)); final long slotAdjustmentsFieldID = 1L; BaseTLVType slotAdjustmentstlvValue = ArrayType.generateArrayType(slotAdjustments, (elementslotAdjustments) -> elementslotAdjustments.encodeTlv()); @@ -31267,7 +31267,7 @@ public void onResponse(StructType invokeStructValue) { } public interface PowerAdjustmentCapabilityAttributeCallback extends BaseAttributeCallback { - void onSuccess(@Nullable List value); + void onSuccess(@Nullable ChipStructs.DeviceEnergyManagementClusterPowerAdjustCapabilityStruct value); } public interface ForecastAttributeCallback extends BaseAttributeCallback { @@ -31427,7 +31427,7 @@ public void readPowerAdjustmentCapabilityAttribute( readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable ChipStructs.DeviceEnergyManagementClusterPowerAdjustCapabilityStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } }, POWER_ADJUSTMENT_CAPABILITY_ATTRIBUTE_ID, true); @@ -31440,7 +31440,7 @@ public void subscribePowerAdjustmentCapabilityAttribute( subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - @Nullable List value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable ChipStructs.DeviceEnergyManagementClusterPowerAdjustCapabilityStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } }, POWER_ADJUSTMENT_CAPABILITY_ATTRIBUTE_ID, minInterval, maxInterval); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java index c8d48cce340e23..426e73b9ab524a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java @@ -7352,13 +7352,165 @@ public String toString() { return output.toString(); } } +public static class DeviceEnergyManagementClusterPowerAdjustStruct { + public Long minPower; + public Long maxPower; + public Long minDuration; + public Long maxDuration; + private static final long MIN_POWER_ID = 0L; + private static final long MAX_POWER_ID = 1L; + private static final long MIN_DURATION_ID = 2L; + private static final long MAX_DURATION_ID = 3L; + + public DeviceEnergyManagementClusterPowerAdjustStruct( + Long minPower, + Long maxPower, + Long minDuration, + Long maxDuration + ) { + this.minPower = minPower; + this.maxPower = maxPower; + this.minDuration = minDuration; + this.maxDuration = maxDuration; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(MIN_POWER_ID, new IntType(minPower))); + values.add(new StructElement(MAX_POWER_ID, new IntType(maxPower))); + values.add(new StructElement(MIN_DURATION_ID, new UIntType(minDuration))); + values.add(new StructElement(MAX_DURATION_ID, new UIntType(maxDuration))); + + return new StructType(values); + } + + public static DeviceEnergyManagementClusterPowerAdjustStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Long minPower = null; + Long maxPower = null; + Long minDuration = null; + Long maxDuration = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == MIN_POWER_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + minPower = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == MAX_POWER_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Int) { + IntType castingValue = element.value(IntType.class); + maxPower = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == MIN_DURATION_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + minDuration = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == MAX_DURATION_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + maxDuration = castingValue.value(Long.class); + } + } + } + return new DeviceEnergyManagementClusterPowerAdjustStruct( + minPower, + maxPower, + minDuration, + maxDuration + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("DeviceEnergyManagementClusterPowerAdjustStruct {\n"); + output.append("\tminPower: "); + output.append(minPower); + output.append("\n"); + output.append("\tmaxPower: "); + output.append(maxPower); + output.append("\n"); + output.append("\tminDuration: "); + output.append(minDuration); + output.append("\n"); + output.append("\tmaxDuration: "); + output.append(maxDuration); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} +public static class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct { + public @Nullable ArrayList powerAdjustCapability; + public Integer cause; + private static final long POWER_ADJUST_CAPABILITY_ID = 0L; + private static final long CAUSE_ID = 1L; + + public DeviceEnergyManagementClusterPowerAdjustCapabilityStruct( + @Nullable ArrayList powerAdjustCapability, + Integer cause + ) { + this.powerAdjustCapability = powerAdjustCapability; + this.cause = cause; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(POWER_ADJUST_CAPABILITY_ID, powerAdjustCapability != null ? ArrayType.generateArrayType(powerAdjustCapability, (elementpowerAdjustCapability) -> elementpowerAdjustCapability.encodeTlv()) : new NullType())); + values.add(new StructElement(CAUSE_ID, new UIntType(cause))); + + return new StructType(values); + } + + public static DeviceEnergyManagementClusterPowerAdjustCapabilityStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + @Nullable ArrayList powerAdjustCapability = null; + Integer cause = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == POWER_ADJUST_CAPABILITY_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Array) { + ArrayType castingValue = element.value(ArrayType.class); + powerAdjustCapability = castingValue.map((elementcastingValue) -> ChipStructs.DeviceEnergyManagementClusterPowerAdjustStruct.decodeTlv(elementcastingValue)); + } + } else if (element.contextTagNum() == CAUSE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + cause = castingValue.value(Integer.class); + } + } + } + return new DeviceEnergyManagementClusterPowerAdjustCapabilityStruct( + powerAdjustCapability, + cause + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("DeviceEnergyManagementClusterPowerAdjustCapabilityStruct {\n"); + output.append("\tpowerAdjustCapability: "); + output.append(powerAdjustCapability); + output.append("\n"); + output.append("\tcause: "); + output.append(cause); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} public static class DeviceEnergyManagementClusterSlotStruct { public Long minDuration; public Long maxDuration; public Long defaultDuration; public Long elapsedSlotTime; public Long remainingSlotTime; - public Optional slotIsPauseable; + public Optional slotIsPausable; public Optional minPauseDuration; public Optional maxPauseDuration; public Optional manufacturerESAState; @@ -7376,7 +7528,7 @@ public static class DeviceEnergyManagementClusterSlotStruct { private static final long DEFAULT_DURATION_ID = 2L; private static final long ELAPSED_SLOT_TIME_ID = 3L; private static final long REMAINING_SLOT_TIME_ID = 4L; - private static final long SLOT_IS_PAUSEABLE_ID = 5L; + private static final long SLOT_IS_PAUSABLE_ID = 5L; private static final long MIN_PAUSE_DURATION_ID = 6L; private static final long MAX_PAUSE_DURATION_ID = 7L; private static final long MANUFACTURER_E_S_A_STATE_ID = 8L; @@ -7396,7 +7548,7 @@ public DeviceEnergyManagementClusterSlotStruct( Long defaultDuration, Long elapsedSlotTime, Long remainingSlotTime, - Optional slotIsPauseable, + Optional slotIsPausable, Optional minPauseDuration, Optional maxPauseDuration, Optional manufacturerESAState, @@ -7415,7 +7567,7 @@ public DeviceEnergyManagementClusterSlotStruct( this.defaultDuration = defaultDuration; this.elapsedSlotTime = elapsedSlotTime; this.remainingSlotTime = remainingSlotTime; - this.slotIsPauseable = slotIsPauseable; + this.slotIsPausable = slotIsPausable; this.minPauseDuration = minPauseDuration; this.maxPauseDuration = maxPauseDuration; this.manufacturerESAState = manufacturerESAState; @@ -7437,7 +7589,7 @@ public StructType encodeTlv() { values.add(new StructElement(DEFAULT_DURATION_ID, new UIntType(defaultDuration))); values.add(new StructElement(ELAPSED_SLOT_TIME_ID, new UIntType(elapsedSlotTime))); values.add(new StructElement(REMAINING_SLOT_TIME_ID, new UIntType(remainingSlotTime))); - values.add(new StructElement(SLOT_IS_PAUSEABLE_ID, slotIsPauseable.map((nonOptionalslotIsPauseable) -> new BooleanType(nonOptionalslotIsPauseable)).orElse(new EmptyType()))); + values.add(new StructElement(SLOT_IS_PAUSABLE_ID, slotIsPausable.map((nonOptionalslotIsPausable) -> new BooleanType(nonOptionalslotIsPausable)).orElse(new EmptyType()))); values.add(new StructElement(MIN_PAUSE_DURATION_ID, minPauseDuration.map((nonOptionalminPauseDuration) -> new UIntType(nonOptionalminPauseDuration)).orElse(new EmptyType()))); values.add(new StructElement(MAX_PAUSE_DURATION_ID, maxPauseDuration.map((nonOptionalmaxPauseDuration) -> new UIntType(nonOptionalmaxPauseDuration)).orElse(new EmptyType()))); values.add(new StructElement(MANUFACTURER_E_S_A_STATE_ID, manufacturerESAState.map((nonOptionalmanufacturerESAState) -> new UIntType(nonOptionalmanufacturerESAState)).orElse(new EmptyType()))); @@ -7463,7 +7615,7 @@ public static DeviceEnergyManagementClusterSlotStruct decodeTlv(BaseTLVType tlvV Long defaultDuration = null; Long elapsedSlotTime = null; Long remainingSlotTime = null; - Optional slotIsPauseable = Optional.empty(); + Optional slotIsPausable = Optional.empty(); Optional minPauseDuration = Optional.empty(); Optional maxPauseDuration = Optional.empty(); Optional manufacturerESAState = Optional.empty(); @@ -7502,10 +7654,10 @@ public static DeviceEnergyManagementClusterSlotStruct decodeTlv(BaseTLVType tlvV UIntType castingValue = element.value(UIntType.class); remainingSlotTime = castingValue.value(Long.class); } - } else if (element.contextTagNum() == SLOT_IS_PAUSEABLE_ID) { + } else if (element.contextTagNum() == SLOT_IS_PAUSABLE_ID) { if (element.value(BaseTLVType.class).type() == TLVType.Boolean) { BooleanType castingValue = element.value(BooleanType.class); - slotIsPauseable = Optional.of(castingValue.value(Boolean.class)); + slotIsPausable = Optional.of(castingValue.value(Boolean.class)); } } else if (element.contextTagNum() == MIN_PAUSE_DURATION_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -7575,7 +7727,7 @@ public static DeviceEnergyManagementClusterSlotStruct decodeTlv(BaseTLVType tlvV defaultDuration, elapsedSlotTime, remainingSlotTime, - slotIsPauseable, + slotIsPausable, minPauseDuration, maxPauseDuration, manufacturerESAState, @@ -7610,8 +7762,8 @@ public String toString() { output.append("\tremainingSlotTime: "); output.append(remainingSlotTime); output.append("\n"); - output.append("\tslotIsPauseable: "); - output.append(slotIsPauseable); + output.append("\tslotIsPausable: "); + output.append(slotIsPausable); output.append("\n"); output.append("\tminPauseDuration: "); output.append(minPauseDuration); @@ -7654,56 +7806,56 @@ public String toString() { } } public static class DeviceEnergyManagementClusterForecastStruct { - public Integer forecastId; + public Long forecastID; public @Nullable Integer activeSlotNumber; public Long startTime; public Long endTime; public @Nullable Optional earliestStartTime; public Optional latestEndTime; - public Boolean isPauseable; + public Boolean isPausable; public ArrayList slots; public Integer forecastUpdateReason; - private static final long FORECAST_ID_ID = 0L; + private static final long FORECAST_I_D_ID = 0L; private static final long ACTIVE_SLOT_NUMBER_ID = 1L; private static final long START_TIME_ID = 2L; private static final long END_TIME_ID = 3L; private static final long EARLIEST_START_TIME_ID = 4L; private static final long LATEST_END_TIME_ID = 5L; - private static final long IS_PAUSEABLE_ID = 6L; + private static final long IS_PAUSABLE_ID = 6L; private static final long SLOTS_ID = 7L; private static final long FORECAST_UPDATE_REASON_ID = 8L; public DeviceEnergyManagementClusterForecastStruct( - Integer forecastId, + Long forecastID, @Nullable Integer activeSlotNumber, Long startTime, Long endTime, @Nullable Optional earliestStartTime, Optional latestEndTime, - Boolean isPauseable, + Boolean isPausable, ArrayList slots, Integer forecastUpdateReason ) { - this.forecastId = forecastId; + this.forecastID = forecastID; this.activeSlotNumber = activeSlotNumber; this.startTime = startTime; this.endTime = endTime; this.earliestStartTime = earliestStartTime; this.latestEndTime = latestEndTime; - this.isPauseable = isPauseable; + this.isPausable = isPausable; this.slots = slots; this.forecastUpdateReason = forecastUpdateReason; } public StructType encodeTlv() { ArrayList values = new ArrayList<>(); - values.add(new StructElement(FORECAST_ID_ID, new UIntType(forecastId))); + values.add(new StructElement(FORECAST_I_D_ID, new UIntType(forecastID))); values.add(new StructElement(ACTIVE_SLOT_NUMBER_ID, activeSlotNumber != null ? new UIntType(activeSlotNumber) : new NullType())); values.add(new StructElement(START_TIME_ID, new UIntType(startTime))); values.add(new StructElement(END_TIME_ID, new UIntType(endTime))); values.add(new StructElement(EARLIEST_START_TIME_ID, earliestStartTime != null ? earliestStartTime.map((nonOptionalearliestStartTime) -> new UIntType(nonOptionalearliestStartTime)).orElse(new EmptyType()) : new NullType())); values.add(new StructElement(LATEST_END_TIME_ID, latestEndTime.map((nonOptionallatestEndTime) -> new UIntType(nonOptionallatestEndTime)).orElse(new EmptyType()))); - values.add(new StructElement(IS_PAUSEABLE_ID, new BooleanType(isPauseable))); + values.add(new StructElement(IS_PAUSABLE_ID, new BooleanType(isPausable))); values.add(new StructElement(SLOTS_ID, ArrayType.generateArrayType(slots, (elementslots) -> elementslots.encodeTlv()))); values.add(new StructElement(FORECAST_UPDATE_REASON_ID, new UIntType(forecastUpdateReason))); @@ -7714,20 +7866,20 @@ public static DeviceEnergyManagementClusterForecastStruct decodeTlv(BaseTLVType if (tlvValue == null || tlvValue.type() != TLVType.Struct) { return null; } - Integer forecastId = null; + Long forecastID = null; @Nullable Integer activeSlotNumber = null; Long startTime = null; Long endTime = null; @Nullable Optional earliestStartTime = null; Optional latestEndTime = Optional.empty(); - Boolean isPauseable = null; + Boolean isPausable = null; ArrayList slots = null; Integer forecastUpdateReason = null; for (StructElement element: ((StructType)tlvValue).value()) { - if (element.contextTagNum() == FORECAST_ID_ID) { + if (element.contextTagNum() == FORECAST_I_D_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { UIntType castingValue = element.value(UIntType.class); - forecastId = castingValue.value(Integer.class); + forecastID = castingValue.value(Long.class); } } else if (element.contextTagNum() == ACTIVE_SLOT_NUMBER_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -7754,10 +7906,10 @@ public static DeviceEnergyManagementClusterForecastStruct decodeTlv(BaseTLVType UIntType castingValue = element.value(UIntType.class); latestEndTime = Optional.of(castingValue.value(Long.class)); } - } else if (element.contextTagNum() == IS_PAUSEABLE_ID) { + } else if (element.contextTagNum() == IS_PAUSABLE_ID) { if (element.value(BaseTLVType.class).type() == TLVType.Boolean) { BooleanType castingValue = element.value(BooleanType.class); - isPauseable = castingValue.value(Boolean.class); + isPausable = castingValue.value(Boolean.class); } } else if (element.contextTagNum() == SLOTS_ID) { if (element.value(BaseTLVType.class).type() == TLVType.Array) { @@ -7772,13 +7924,13 @@ public static DeviceEnergyManagementClusterForecastStruct decodeTlv(BaseTLVType } } return new DeviceEnergyManagementClusterForecastStruct( - forecastId, + forecastID, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, - isPauseable, + isPausable, slots, forecastUpdateReason ); @@ -7788,8 +7940,8 @@ public static DeviceEnergyManagementClusterForecastStruct decodeTlv(BaseTLVType public String toString() { StringBuilder output = new StringBuilder(); output.append("DeviceEnergyManagementClusterForecastStruct {\n"); - output.append("\tforecastId: "); - output.append(forecastId); + output.append("\tforecastID: "); + output.append(forecastID); output.append("\n"); output.append("\tactiveSlotNumber: "); output.append(activeSlotNumber); @@ -7806,8 +7958,8 @@ public String toString() { output.append("\tlatestEndTime: "); output.append(latestEndTime); output.append("\n"); - output.append("\tisPauseable: "); - output.append(isPauseable); + output.append("\tisPausable: "); + output.append(isPausable); output.append("\n"); output.append("\tslots: "); output.append(slots); @@ -7925,100 +8077,9 @@ public String toString() { return output.toString(); } } -public static class DeviceEnergyManagementClusterPowerAdjustStruct { - public Long minPower; - public Long maxPower; - public Long minDuration; - public Long maxDuration; - private static final long MIN_POWER_ID = 0L; - private static final long MAX_POWER_ID = 1L; - private static final long MIN_DURATION_ID = 2L; - private static final long MAX_DURATION_ID = 3L; - - public DeviceEnergyManagementClusterPowerAdjustStruct( - Long minPower, - Long maxPower, - Long minDuration, - Long maxDuration - ) { - this.minPower = minPower; - this.maxPower = maxPower; - this.minDuration = minDuration; - this.maxDuration = maxDuration; - } - - public StructType encodeTlv() { - ArrayList values = new ArrayList<>(); - values.add(new StructElement(MIN_POWER_ID, new IntType(minPower))); - values.add(new StructElement(MAX_POWER_ID, new IntType(maxPower))); - values.add(new StructElement(MIN_DURATION_ID, new UIntType(minDuration))); - values.add(new StructElement(MAX_DURATION_ID, new UIntType(maxDuration))); - - return new StructType(values); - } - - public static DeviceEnergyManagementClusterPowerAdjustStruct decodeTlv(BaseTLVType tlvValue) { - if (tlvValue == null || tlvValue.type() != TLVType.Struct) { - return null; - } - Long minPower = null; - Long maxPower = null; - Long minDuration = null; - Long maxDuration = null; - for (StructElement element: ((StructType)tlvValue).value()) { - if (element.contextTagNum() == MIN_POWER_ID) { - if (element.value(BaseTLVType.class).type() == TLVType.Int) { - IntType castingValue = element.value(IntType.class); - minPower = castingValue.value(Long.class); - } - } else if (element.contextTagNum() == MAX_POWER_ID) { - if (element.value(BaseTLVType.class).type() == TLVType.Int) { - IntType castingValue = element.value(IntType.class); - maxPower = castingValue.value(Long.class); - } - } else if (element.contextTagNum() == MIN_DURATION_ID) { - if (element.value(BaseTLVType.class).type() == TLVType.UInt) { - UIntType castingValue = element.value(UIntType.class); - minDuration = castingValue.value(Long.class); - } - } else if (element.contextTagNum() == MAX_DURATION_ID) { - if (element.value(BaseTLVType.class).type() == TLVType.UInt) { - UIntType castingValue = element.value(UIntType.class); - maxDuration = castingValue.value(Long.class); - } - } - } - return new DeviceEnergyManagementClusterPowerAdjustStruct( - minPower, - maxPower, - minDuration, - maxDuration - ); - } - - @Override - public String toString() { - StringBuilder output = new StringBuilder(); - output.append("DeviceEnergyManagementClusterPowerAdjustStruct {\n"); - output.append("\tminPower: "); - output.append(minPower); - output.append("\n"); - output.append("\tmaxPower: "); - output.append(maxPower); - output.append("\n"); - output.append("\tminDuration: "); - output.append(minDuration); - output.append("\n"); - output.append("\tmaxDuration: "); - output.append(maxDuration); - output.append("\n"); - output.append("}\n"); - return output.toString(); - } -} public static class DeviceEnergyManagementClusterSlotAdjustmentStruct { public Integer slotIndex; - public Long nominalPower; + public Optional nominalPower; public Long duration; private static final long SLOT_INDEX_ID = 0L; private static final long NOMINAL_POWER_ID = 1L; @@ -8026,7 +8087,7 @@ public static class DeviceEnergyManagementClusterSlotAdjustmentStruct { public DeviceEnergyManagementClusterSlotAdjustmentStruct( Integer slotIndex, - Long nominalPower, + Optional nominalPower, Long duration ) { this.slotIndex = slotIndex; @@ -8037,7 +8098,7 @@ public DeviceEnergyManagementClusterSlotAdjustmentStruct( public StructType encodeTlv() { ArrayList values = new ArrayList<>(); values.add(new StructElement(SLOT_INDEX_ID, new UIntType(slotIndex))); - values.add(new StructElement(NOMINAL_POWER_ID, new IntType(nominalPower))); + values.add(new StructElement(NOMINAL_POWER_ID, nominalPower.map((nonOptionalnominalPower) -> new IntType(nonOptionalnominalPower)).orElse(new EmptyType()))); values.add(new StructElement(DURATION_ID, new UIntType(duration))); return new StructType(values); @@ -8048,7 +8109,7 @@ public static DeviceEnergyManagementClusterSlotAdjustmentStruct decodeTlv(BaseTL return null; } Integer slotIndex = null; - Long nominalPower = null; + Optional nominalPower = Optional.empty(); Long duration = null; for (StructElement element: ((StructType)tlvValue).value()) { if (element.contextTagNum() == SLOT_INDEX_ID) { @@ -8059,7 +8120,7 @@ public static DeviceEnergyManagementClusterSlotAdjustmentStruct decodeTlv(BaseTL } else if (element.contextTagNum() == NOMINAL_POWER_ID) { if (element.value(BaseTLVType.class).type() == TLVType.Int) { IntType castingValue = element.value(IntType.class); - nominalPower = castingValue.value(Long.class); + nominalPower = Optional.of(castingValue.value(Long.class)); } } else if (element.contextTagNum() == DURATION_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index cd89fd9df6d472..dc151ff539e87c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -9758,7 +9758,7 @@ public static PauseRequestCommandField value(int id) throws NoSuchFieldError { } throw new NoSuchFieldError(); } - }public enum ModifyForecastRequestCommandField {ForecastId(0),SlotAdjustments(1),Cause(2),; + }public enum ModifyForecastRequestCommandField {ForecastID(0),SlotAdjustments(1),Cause(2),; private final int id; ModifyForecastRequestCommandField(int id) { this.id = id; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index 47ee02f5ede86c..1fff0ce5ab058e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -10882,10 +10882,10 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(@Nullable List valueList) { + public void onSuccess(@Nullable ChipStructs.DeviceEnergyManagementClusterPowerAdjustCapabilityStruct value) { Map responseValues = new LinkedHashMap<>(); - CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); - responseValues.put(commandResponseInfo, valueList); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.DeviceEnergyManagementClusterPowerAdjustCapabilityStruct"); + responseValues.put(commandResponseInfo, value); callback.onSuccess(responseValues); } @@ -24765,8 +24765,8 @@ public Map> getCommandMap() { Map deviceEnergyManagementmodifyForecastRequestCommandParams = new LinkedHashMap(); - CommandParameterInfo deviceEnergyManagementmodifyForecastRequestforecastIdCommandParameterInfo = new CommandParameterInfo("forecastId", Long.class, Long.class); - deviceEnergyManagementmodifyForecastRequestCommandParams.put("forecastId",deviceEnergyManagementmodifyForecastRequestforecastIdCommandParameterInfo); + CommandParameterInfo deviceEnergyManagementmodifyForecastRequestforecastIDCommandParameterInfo = new CommandParameterInfo("forecastID", Long.class, Long.class); + deviceEnergyManagementmodifyForecastRequestCommandParams.put("forecastID",deviceEnergyManagementmodifyForecastRequestforecastIDCommandParameterInfo); CommandParameterInfo deviceEnergyManagementmodifyForecastRequestcauseCommandParameterInfo = new CommandParameterInfo("cause", Integer.class, Integer.class); @@ -24776,7 +24776,7 @@ public Map> getCommandMap() { ((ChipClusters.DeviceEnergyManagementCluster) cluster) .modifyForecastRequest((DefaultClusterCallback) callback , (Long) - commandArguments.get("forecastId") + commandArguments.get("forecastID") , (ArrayList) commandArguments.get("slotAdjustments") , (Integer) diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index c607d8deca891a..31ebc455b56aaa 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -9619,17 +9619,6 @@ private static Map readDeviceEnergyManagementInteractio readDeviceEnergyManagementAbsMaxPowerCommandParams ); result.put("readAbsMaxPowerAttribute", readDeviceEnergyManagementAbsMaxPowerAttributeInteractionInfo); - Map readDeviceEnergyManagementPowerAdjustmentCapabilityCommandParams = new LinkedHashMap(); - InteractionInfo readDeviceEnergyManagementPowerAdjustmentCapabilityAttributeInteractionInfo = new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.DeviceEnergyManagementCluster) cluster).readPowerAdjustmentCapabilityAttribute( - (ChipClusters.DeviceEnergyManagementCluster.PowerAdjustmentCapabilityAttributeCallback) callback - ); - }, - () -> new ClusterInfoMapping.DelegatedDeviceEnergyManagementClusterPowerAdjustmentCapabilityAttributeCallback(), - readDeviceEnergyManagementPowerAdjustmentCapabilityCommandParams - ); - result.put("readPowerAdjustmentCapabilityAttribute", readDeviceEnergyManagementPowerAdjustmentCapabilityAttributeInteractionInfo); Map readDeviceEnergyManagementOptOutStateCommandParams = new LinkedHashMap(); InteractionInfo readDeviceEnergyManagementOptOutStateAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni index 4f8bcd19a75f60..a5f7518b9c8766 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -47,6 +47,7 @@ structs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt", diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index 17e45fa732ea47..ad9120a2327983 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -25,25 +25,25 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class DeviceEnergyManagementClusterForecastStruct( - val forecastId: UInt, + val forecastID: ULong, val activeSlotNumber: UInt?, val startTime: ULong, val endTime: ULong, val earliestStartTime: Optional?, val latestEndTime: Optional, - val isPauseable: Boolean, + val isPausable: Boolean, val slots: List, val forecastUpdateReason: UInt ) { override fun toString(): String = buildString { append("DeviceEnergyManagementClusterForecastStruct {\n") - append("\tforecastId : $forecastId\n") + append("\tforecastID : $forecastID\n") append("\tactiveSlotNumber : $activeSlotNumber\n") append("\tstartTime : $startTime\n") append("\tendTime : $endTime\n") append("\tearliestStartTime : $earliestStartTime\n") append("\tlatestEndTime : $latestEndTime\n") - append("\tisPauseable : $isPauseable\n") + append("\tisPausable : $isPausable\n") append("\tslots : $slots\n") append("\tforecastUpdateReason : $forecastUpdateReason\n") append("}\n") @@ -52,7 +52,7 @@ class DeviceEnergyManagementClusterForecastStruct( fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { tlvWriter.apply { startStructure(tlvTag) - put(ContextSpecificTag(TAG_FORECAST_ID), forecastId) + put(ContextSpecificTag(TAG_FORECAST_I_D), forecastID) if (activeSlotNumber != null) { put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) } else { @@ -72,7 +72,7 @@ class DeviceEnergyManagementClusterForecastStruct( val optlatestEndTime = latestEndTime.get() put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) } - put(ContextSpecificTag(TAG_IS_PAUSEABLE), isPauseable) + put(ContextSpecificTag(TAG_IS_PAUSABLE), isPausable) startArray(ContextSpecificTag(TAG_SLOTS)) for (item in slots.iterator()) { item.toTlv(AnonymousTag, this) @@ -84,19 +84,19 @@ class DeviceEnergyManagementClusterForecastStruct( } companion object { - private const val TAG_FORECAST_ID = 0 + private const val TAG_FORECAST_I_D = 0 private const val TAG_ACTIVE_SLOT_NUMBER = 1 private const val TAG_START_TIME = 2 private const val TAG_END_TIME = 3 private const val TAG_EARLIEST_START_TIME = 4 private const val TAG_LATEST_END_TIME = 5 - private const val TAG_IS_PAUSEABLE = 6 + private const val TAG_IS_PAUSABLE = 6 private const val TAG_SLOTS = 7 private const val TAG_FORECAST_UPDATE_REASON = 8 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) - val forecastId = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_ID)) + val forecastID = tlvReader.getULong(ContextSpecificTag(TAG_FORECAST_I_D)) val activeSlotNumber = if (!tlvReader.isNull()) { tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) @@ -123,7 +123,7 @@ class DeviceEnergyManagementClusterForecastStruct( } else { Optional.empty() } - val isPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSEABLE)) + val isPausable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSABLE)) val slots = buildList { tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) @@ -137,13 +137,13 @@ class DeviceEnergyManagementClusterForecastStruct( tlvReader.exitContainer() return DeviceEnergyManagementClusterForecastStruct( - forecastId, + forecastID, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, - isPauseable, + isPausable, slots, forecastUpdateReason ) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt new file mode 100644 index 00000000000000..e2172a7b33b94e --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt @@ -0,0 +1,83 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct( + val powerAdjustCapability: List?, + val cause: UInt +) { + override fun toString(): String = buildString { + append("DeviceEnergyManagementClusterPowerAdjustCapabilityStruct {\n") + append("\tpowerAdjustCapability : $powerAdjustCapability\n") + append("\tcause : $cause\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (powerAdjustCapability != null) { + startArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + for (item in powerAdjustCapability.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + } + put(ContextSpecificTag(TAG_CAUSE), cause) + endStructure() + } + } + + companion object { + private const val TAG_POWER_ADJUST_CAPABILITY = 0 + private const val TAG_CAUSE = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustCapabilityStruct { + tlvReader.enterStructure(tlvTag) + val powerAdjustCapability = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + null + } + val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) + + tlvReader.exitContainer() + + return DeviceEnergyManagementClusterPowerAdjustCapabilityStruct(powerAdjustCapability, cause) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index 11fcf975e99039..22aa9bdae17234 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -17,6 +17,7 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -24,7 +25,7 @@ import matter.tlv.TlvWriter class DeviceEnergyManagementClusterSlotAdjustmentStruct( val slotIndex: UInt, - val nominalPower: Long, + val nominalPower: Optional, val duration: ULong ) { override fun toString(): String = buildString { @@ -39,7 +40,10 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( tlvWriter.apply { startStructure(tlvTag) put(ContextSpecificTag(TAG_SLOT_INDEX), slotIndex) - put(ContextSpecificTag(TAG_NOMINAL_POWER), nominalPower) + if (nominalPower.isPresent) { + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } put(ContextSpecificTag(TAG_DURATION), duration) endStructure() } @@ -56,7 +60,12 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( ): DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUInt(ContextSpecificTag(TAG_SLOT_INDEX)) - val nominalPower = tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER)) + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 18759432dc2ce4..f6d35be87d59f3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -30,7 +30,7 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration: ULong, val elapsedSlotTime: ULong, val remainingSlotTime: ULong, - val slotIsPauseable: Optional, + val slotIsPausable: Optional, val minPauseDuration: Optional, val maxPauseDuration: Optional, val manufacturerESAState: Optional, @@ -51,7 +51,7 @@ class DeviceEnergyManagementClusterSlotStruct( append("\tdefaultDuration : $defaultDuration\n") append("\telapsedSlotTime : $elapsedSlotTime\n") append("\tremainingSlotTime : $remainingSlotTime\n") - append("\tslotIsPauseable : $slotIsPauseable\n") + append("\tslotIsPausable : $slotIsPausable\n") append("\tminPauseDuration : $minPauseDuration\n") append("\tmaxPauseDuration : $maxPauseDuration\n") append("\tmanufacturerESAState : $manufacturerESAState\n") @@ -75,9 +75,9 @@ class DeviceEnergyManagementClusterSlotStruct( put(ContextSpecificTag(TAG_DEFAULT_DURATION), defaultDuration) put(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME), elapsedSlotTime) put(ContextSpecificTag(TAG_REMAINING_SLOT_TIME), remainingSlotTime) - if (slotIsPauseable.isPresent) { - val optslotIsPauseable = slotIsPauseable.get() - put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) + if (slotIsPausable.isPresent) { + val optslotIsPausable = slotIsPausable.get() + put(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE), optslotIsPausable) } if (minPauseDuration.isPresent) { val optminPauseDuration = minPauseDuration.get() @@ -141,7 +141,7 @@ class DeviceEnergyManagementClusterSlotStruct( private const val TAG_DEFAULT_DURATION = 2 private const val TAG_ELAPSED_SLOT_TIME = 3 private const val TAG_REMAINING_SLOT_TIME = 4 - private const val TAG_SLOT_IS_PAUSEABLE = 5 + private const val TAG_SLOT_IS_PAUSABLE = 5 private const val TAG_MIN_PAUSE_DURATION = 6 private const val TAG_MAX_PAUSE_DURATION = 7 private const val TAG_MANUFACTURER_E_S_A_STATE = 8 @@ -162,9 +162,9 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration = tlvReader.getULong(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + val slotIsPausable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) } else { Optional.empty() } @@ -257,7 +257,7 @@ class DeviceEnergyManagementClusterSlotStruct( defaultDuration, elapsedSlotTime, remainingSlotTime, - slotIsPauseable, + slotIsPausable, minPauseDuration, maxPauseDuration, manufacturerESAState, diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt index eb68ec47c75ee1..6549ec01a70fed 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt @@ -47,11 +47,11 @@ class DeviceEnergyManagementCluster( private val endpointId: UShort ) { class PowerAdjustmentCapabilityAttribute( - val value: List? + val value: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? ) sealed class PowerAdjustmentCapabilityAttributeSubscriptionState { - data class Success(val value: List?) : + data class Success(val value: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct?) : PowerAdjustmentCapabilityAttributeSubscriptionState() data class Error(val exception: Exception) : @@ -232,7 +232,7 @@ class DeviceEnergyManagementCluster( } suspend fun modifyForecastRequest( - forecastId: UInt, + forecastID: UInt, slotAdjustments: List, cause: UByte, timedInvokeTimeout: Duration? = null @@ -242,8 +242,8 @@ class DeviceEnergyManagementCluster( val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) - val TAG_FORECAST_ID_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_FORECAST_ID_REQ), forecastId) + val TAG_FORECAST_I_D_REQ: Int = 0 + tlvWriter.put(ContextSpecificTag(TAG_FORECAST_I_D_REQ), forecastID) val TAG_SLOT_ADJUSTMENTS_REQ: Int = 1 tlvWriter.startArray(ContextSpecificTag(TAG_SLOT_ADJUSTMENTS_REQ)) @@ -750,16 +750,10 @@ class DeviceEnergyManagementCluster( // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = + val decodedValue: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? = if (!tlvReader.isNull()) { if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.fromTlv(AnonymousTag, tlvReader) } else { null } @@ -812,21 +806,13 @@ class DeviceEnergyManagementCluster( // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = + val decodedValue: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? = if (!tlvReader.isNull()) { if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.fromTlv( + AnonymousTag, + tlvReader + ) } else { null } diff --git a/src/controller/java/generated/java/matter/controller/cluster/files.gni b/src/controller/java/generated/java/matter/controller/cluster/files.gni index f7670310f95cfd..dd0a570e5526f3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -47,6 +47,7 @@ matter_structs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt", diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index a83d26ee3815d0..f78288a7493666 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -25,25 +25,25 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class DeviceEnergyManagementClusterForecastStruct( - val forecastId: UShort, + val forecastID: UInt, val activeSlotNumber: UShort?, val startTime: UInt, val endTime: UInt, val earliestStartTime: Optional?, val latestEndTime: Optional, - val isPauseable: Boolean, + val isPausable: Boolean, val slots: List, val forecastUpdateReason: UByte ) { override fun toString(): String = buildString { append("DeviceEnergyManagementClusterForecastStruct {\n") - append("\tforecastId : $forecastId\n") + append("\tforecastID : $forecastID\n") append("\tactiveSlotNumber : $activeSlotNumber\n") append("\tstartTime : $startTime\n") append("\tendTime : $endTime\n") append("\tearliestStartTime : $earliestStartTime\n") append("\tlatestEndTime : $latestEndTime\n") - append("\tisPauseable : $isPauseable\n") + append("\tisPausable : $isPausable\n") append("\tslots : $slots\n") append("\tforecastUpdateReason : $forecastUpdateReason\n") append("}\n") @@ -52,7 +52,7 @@ class DeviceEnergyManagementClusterForecastStruct( fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { tlvWriter.apply { startStructure(tlvTag) - put(ContextSpecificTag(TAG_FORECAST_ID), forecastId) + put(ContextSpecificTag(TAG_FORECAST_I_D), forecastID) if (activeSlotNumber != null) { put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) } else { @@ -72,7 +72,7 @@ class DeviceEnergyManagementClusterForecastStruct( val optlatestEndTime = latestEndTime.get() put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) } - put(ContextSpecificTag(TAG_IS_PAUSEABLE), isPauseable) + put(ContextSpecificTag(TAG_IS_PAUSABLE), isPausable) startArray(ContextSpecificTag(TAG_SLOTS)) for (item in slots.iterator()) { item.toTlv(AnonymousTag, this) @@ -84,19 +84,19 @@ class DeviceEnergyManagementClusterForecastStruct( } companion object { - private const val TAG_FORECAST_ID = 0 + private const val TAG_FORECAST_I_D = 0 private const val TAG_ACTIVE_SLOT_NUMBER = 1 private const val TAG_START_TIME = 2 private const val TAG_END_TIME = 3 private const val TAG_EARLIEST_START_TIME = 4 private const val TAG_LATEST_END_TIME = 5 - private const val TAG_IS_PAUSEABLE = 6 + private const val TAG_IS_PAUSABLE = 6 private const val TAG_SLOTS = 7 private const val TAG_FORECAST_UPDATE_REASON = 8 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) - val forecastId = tlvReader.getUShort(ContextSpecificTag(TAG_FORECAST_ID)) + val forecastID = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_I_D)) val activeSlotNumber = if (!tlvReader.isNull()) { tlvReader.getUShort(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) @@ -123,7 +123,7 @@ class DeviceEnergyManagementClusterForecastStruct( } else { Optional.empty() } - val isPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSEABLE)) + val isPausable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSABLE)) val slots = buildList { tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) @@ -137,13 +137,13 @@ class DeviceEnergyManagementClusterForecastStruct( tlvReader.exitContainer() return DeviceEnergyManagementClusterForecastStruct( - forecastId, + forecastID, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, - isPauseable, + isPausable, slots, forecastUpdateReason ) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt new file mode 100644 index 00000000000000..eda6c168281800 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt @@ -0,0 +1,83 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package matter.controller.cluster.structs + +import matter.controller.cluster.* +import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct( + val powerAdjustCapability: List?, + val cause: UByte +) { + override fun toString(): String = buildString { + append("DeviceEnergyManagementClusterPowerAdjustCapabilityStruct {\n") + append("\tpowerAdjustCapability : $powerAdjustCapability\n") + append("\tcause : $cause\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + if (powerAdjustCapability != null) { + startArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + for (item in powerAdjustCapability.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + } + put(ContextSpecificTag(TAG_CAUSE), cause) + endStructure() + } + } + + companion object { + private const val TAG_POWER_ADJUST_CAPABILITY = 0 + private const val TAG_CAUSE = 1 + + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustCapabilityStruct { + tlvReader.enterStructure(tlvTag) + val powerAdjustCapability = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + null + } + val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) + + tlvReader.exitContainer() + + return DeviceEnergyManagementClusterPowerAdjustCapabilityStruct(powerAdjustCapability, cause) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index e11febdfd6a489..5d4cef6567816d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -24,7 +25,7 @@ import matter.tlv.TlvWriter class DeviceEnergyManagementClusterSlotAdjustmentStruct( val slotIndex: UByte, - val nominalPower: Long, + val nominalPower: Optional, val duration: UInt ) { override fun toString(): String = buildString { @@ -39,7 +40,10 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( tlvWriter.apply { startStructure(tlvTag) put(ContextSpecificTag(TAG_SLOT_INDEX), slotIndex) - put(ContextSpecificTag(TAG_NOMINAL_POWER), nominalPower) + if (nominalPower.isPresent) { + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } put(ContextSpecificTag(TAG_DURATION), duration) endStructure() } @@ -56,7 +60,12 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( ): DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUByte(ContextSpecificTag(TAG_SLOT_INDEX)) - val nominalPower = tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER)) + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) tlvReader.exitContainer() diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 992a41573e295e..7759d960c31fde 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -30,7 +30,7 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration: UInt, val elapsedSlotTime: UInt, val remainingSlotTime: UInt, - val slotIsPauseable: Optional, + val slotIsPausable: Optional, val minPauseDuration: Optional, val maxPauseDuration: Optional, val manufacturerESAState: Optional, @@ -51,7 +51,7 @@ class DeviceEnergyManagementClusterSlotStruct( append("\tdefaultDuration : $defaultDuration\n") append("\telapsedSlotTime : $elapsedSlotTime\n") append("\tremainingSlotTime : $remainingSlotTime\n") - append("\tslotIsPauseable : $slotIsPauseable\n") + append("\tslotIsPausable : $slotIsPausable\n") append("\tminPauseDuration : $minPauseDuration\n") append("\tmaxPauseDuration : $maxPauseDuration\n") append("\tmanufacturerESAState : $manufacturerESAState\n") @@ -75,9 +75,9 @@ class DeviceEnergyManagementClusterSlotStruct( put(ContextSpecificTag(TAG_DEFAULT_DURATION), defaultDuration) put(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME), elapsedSlotTime) put(ContextSpecificTag(TAG_REMAINING_SLOT_TIME), remainingSlotTime) - if (slotIsPauseable.isPresent) { - val optslotIsPauseable = slotIsPauseable.get() - put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) + if (slotIsPausable.isPresent) { + val optslotIsPausable = slotIsPausable.get() + put(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE), optslotIsPausable) } if (minPauseDuration.isPresent) { val optminPauseDuration = minPauseDuration.get() @@ -141,7 +141,7 @@ class DeviceEnergyManagementClusterSlotStruct( private const val TAG_DEFAULT_DURATION = 2 private const val TAG_ELAPSED_SLOT_TIME = 3 private const val TAG_REMAINING_SLOT_TIME = 4 - private const val TAG_SLOT_IS_PAUSEABLE = 5 + private const val TAG_SLOT_IS_PAUSABLE = 5 private const val TAG_MIN_PAUSE_DURATION = 6 private const val TAG_MAX_PAUSE_DURATION = 7 private const val TAG_MANUFACTURER_E_S_A_STATE = 8 @@ -162,9 +162,9 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration = tlvReader.getUInt(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + val slotIsPausable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) } else { Optional.empty() } @@ -257,7 +257,7 @@ class DeviceEnergyManagementClusterSlotStruct( defaultDuration, elapsedSlotTime, remainingSlotTime, - slotIsPauseable, + slotIsPausable, minPauseDuration, maxPauseDuration, manufacturerESAState, diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 3b58043e65ee78..31de697930dc33 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -23441,67 +23441,106 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } else { - chip::JniReferences::GetInstance().CreateArrayList(value); - - auto iter_value_1 = cppValue.Value().begin(); - while (iter_value_1.Next()) + jobject value_powerAdjustCapability; + if (cppValue.Value().powerAdjustCapability.IsNull()) { - auto & entry_1 = iter_value_1.GetValue(); - jobject newElement_1; - jobject newElement_1_minPower; - std::string newElement_1_minPowerClassName = "java/lang/Long"; - std::string newElement_1_minPowerCtorSignature = "(J)V"; - jlong jninewElement_1_minPower = static_cast(entry_1.minPower); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_minPowerClassName.c_str(), - newElement_1_minPowerCtorSignature.c_str(), - jninewElement_1_minPower, newElement_1_minPower); - jobject newElement_1_maxPower; - std::string newElement_1_maxPowerClassName = "java/lang/Long"; - std::string newElement_1_maxPowerCtorSignature = "(J)V"; - jlong jninewElement_1_maxPower = static_cast(entry_1.maxPower); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_maxPowerClassName.c_str(), - newElement_1_maxPowerCtorSignature.c_str(), - jninewElement_1_maxPower, newElement_1_maxPower); - jobject newElement_1_minDuration; - std::string newElement_1_minDurationClassName = "java/lang/Long"; - std::string newElement_1_minDurationCtorSignature = "(J)V"; - jlong jninewElement_1_minDuration = static_cast(entry_1.minDuration); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1_minDurationClassName.c_str(), newElement_1_minDurationCtorSignature.c_str(), - jninewElement_1_minDuration, newElement_1_minDuration); - jobject newElement_1_maxDuration; - std::string newElement_1_maxDurationClassName = "java/lang/Long"; - std::string newElement_1_maxDurationCtorSignature = "(J)V"; - jlong jninewElement_1_maxDuration = static_cast(entry_1.maxDuration); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_1_maxDurationClassName.c_str(), newElement_1_maxDurationCtorSignature.c_str(), - jninewElement_1_maxDuration, newElement_1_maxDuration); + value_powerAdjustCapability = nullptr; + } + else + { + chip::JniReferences::GetInstance().CreateArrayList(value_powerAdjustCapability); - jclass powerAdjustStructStructClass_2; - err = chip::JniReferences::GetInstance().GetLocalClassRef( - env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementClusterPowerAdjustStruct", - powerAdjustStructStructClass_2); - if (err != CHIP_NO_ERROR) + auto iter_value_powerAdjustCapability_3 = cppValue.Value().powerAdjustCapability.Value().begin(); + while (iter_value_powerAdjustCapability_3.Next()) { - ChipLogError(Zcl, "Could not find class ChipStructs$DeviceEnergyManagementClusterPowerAdjustStruct"); - return nullptr; - } + auto & entry_3 = iter_value_powerAdjustCapability_3.GetValue(); + jobject newElement_3; + jobject newElement_3_minPower; + std::string newElement_3_minPowerClassName = "java/lang/Long"; + std::string newElement_3_minPowerCtorSignature = "(J)V"; + jlong jninewElement_3_minPower = static_cast(entry_3.minPower); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_3_minPowerClassName.c_str(), newElement_3_minPowerCtorSignature.c_str(), + jninewElement_3_minPower, newElement_3_minPower); + jobject newElement_3_maxPower; + std::string newElement_3_maxPowerClassName = "java/lang/Long"; + std::string newElement_3_maxPowerCtorSignature = "(J)V"; + jlong jninewElement_3_maxPower = static_cast(entry_3.maxPower); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_3_maxPowerClassName.c_str(), newElement_3_maxPowerCtorSignature.c_str(), + jninewElement_3_maxPower, newElement_3_maxPower); + jobject newElement_3_minDuration; + std::string newElement_3_minDurationClassName = "java/lang/Long"; + std::string newElement_3_minDurationCtorSignature = "(J)V"; + jlong jninewElement_3_minDuration = static_cast(entry_3.minDuration); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_3_minDurationClassName.c_str(), newElement_3_minDurationCtorSignature.c_str(), + jninewElement_3_minDuration, newElement_3_minDuration); + jobject newElement_3_maxDuration; + std::string newElement_3_maxDurationClassName = "java/lang/Long"; + std::string newElement_3_maxDurationCtorSignature = "(J)V"; + jlong jninewElement_3_maxDuration = static_cast(entry_3.maxDuration); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_3_maxDurationClassName.c_str(), newElement_3_maxDurationCtorSignature.c_str(), + jninewElement_3_maxDuration, newElement_3_maxDuration); - jmethodID powerAdjustStructStructCtor_2; - err = chip::JniReferences::GetInstance().FindMethod( - env, powerAdjustStructStructClass_2, "", - "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;)V", &powerAdjustStructStructCtor_2); - if (err != CHIP_NO_ERROR || powerAdjustStructStructCtor_2 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$DeviceEnergyManagementClusterPowerAdjustStruct constructor"); - return nullptr; + jclass powerAdjustStructStructClass_4; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementClusterPowerAdjustStruct", + powerAdjustStructStructClass_4); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$DeviceEnergyManagementClusterPowerAdjustStruct"); + return nullptr; + } + + jmethodID powerAdjustStructStructCtor_4; + err = chip::JniReferences::GetInstance().FindMethod( + env, powerAdjustStructStructClass_4, "", + "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;)V", &powerAdjustStructStructCtor_4); + if (err != CHIP_NO_ERROR || powerAdjustStructStructCtor_4 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$DeviceEnergyManagementClusterPowerAdjustStruct constructor"); + return nullptr; + } + + newElement_3 = + env->NewObject(powerAdjustStructStructClass_4, powerAdjustStructStructCtor_4, newElement_3_minPower, + newElement_3_maxPower, newElement_3_minDuration, newElement_3_maxDuration); + chip::JniReferences::GetInstance().AddToList(value_powerAdjustCapability, newElement_3); } + } + jobject value_cause; + std::string value_causeClassName = "java/lang/Integer"; + std::string value_causeCtorSignature = "(I)V"; + jint jnivalue_cause = static_cast(cppValue.Value().cause); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_causeClassName.c_str(), value_causeCtorSignature.c_str(), jnivalue_cause, value_cause); - newElement_1 = - env->NewObject(powerAdjustStructStructClass_2, powerAdjustStructStructCtor_2, newElement_1_minPower, - newElement_1_maxPower, newElement_1_minDuration, newElement_1_maxDuration); - chip::JniReferences::GetInstance().AddToList(value, newElement_1); + jclass powerAdjustCapabilityStructStructClass_1; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$DeviceEnergyManagementClusterPowerAdjustCapabilityStruct", + powerAdjustCapabilityStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$DeviceEnergyManagementClusterPowerAdjustCapabilityStruct"); + return nullptr; } + + jmethodID powerAdjustCapabilityStructStructCtor_1; + err = chip::JniReferences::GetInstance().FindMethod(env, powerAdjustCapabilityStructStructClass_1, "", + "(Ljava/util/ArrayList;Ljava/lang/Integer;)V", + &powerAdjustCapabilityStructStructCtor_1); + if (err != CHIP_NO_ERROR || powerAdjustCapabilityStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$DeviceEnergyManagementClusterPowerAdjustCapabilityStruct constructor"); + return nullptr; + } + + value = env->NewObject(powerAdjustCapabilityStructStructClass_1, powerAdjustCapabilityStructStructCtor_1, + value_powerAdjustCapability, value_cause); } return value; } @@ -23520,13 +23559,13 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } else { - jobject value_forecastId; - std::string value_forecastIdClassName = "java/lang/Integer"; - std::string value_forecastIdCtorSignature = "(I)V"; - jint jnivalue_forecastId = static_cast(cppValue.Value().forecastId); - chip::JniReferences::GetInstance().CreateBoxedObject(value_forecastIdClassName.c_str(), - value_forecastIdCtorSignature.c_str(), - jnivalue_forecastId, value_forecastId); + jobject value_forecastID; + std::string value_forecastIDClassName = "java/lang/Long"; + std::string value_forecastIDCtorSignature = "(J)V"; + jlong jnivalue_forecastID = static_cast(cppValue.Value().forecastID); + chip::JniReferences::GetInstance().CreateBoxedObject(value_forecastIDClassName.c_str(), + value_forecastIDCtorSignature.c_str(), + jnivalue_forecastID, value_forecastID); jobject value_activeSlotNumber; if (cppValue.Value().activeSlotNumber.IsNull()) { @@ -23595,13 +23634,13 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue_latestEndTimeInsideOptional, value_latestEndTimeInsideOptional); chip::JniReferences::GetInstance().CreateOptional(value_latestEndTimeInsideOptional, value_latestEndTime); } - jobject value_isPauseable; - std::string value_isPauseableClassName = "java/lang/Boolean"; - std::string value_isPauseableCtorSignature = "(Z)V"; - jboolean jnivalue_isPauseable = static_cast(cppValue.Value().isPauseable); - chip::JniReferences::GetInstance().CreateBoxedObject(value_isPauseableClassName.c_str(), - value_isPauseableCtorSignature.c_str(), - jnivalue_isPauseable, value_isPauseable); + jobject value_isPausable; + std::string value_isPausableClassName = "java/lang/Boolean"; + std::string value_isPausableCtorSignature = "(Z)V"; + jboolean jnivalue_isPausable = static_cast(cppValue.Value().isPausable); + chip::JniReferences::GetInstance().CreateBoxedObject(value_isPausableClassName.c_str(), + value_isPausableCtorSignature.c_str(), + jnivalue_isPausable, value_isPausable); jobject value_slots; chip::JniReferences::GetInstance().CreateArrayList(value_slots); @@ -23645,24 +23684,24 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR chip::JniReferences::GetInstance().CreateBoxedObject( newElement_2_remainingSlotTimeClassName.c_str(), newElement_2_remainingSlotTimeCtorSignature.c_str(), jninewElement_2_remainingSlotTime, newElement_2_remainingSlotTime); - jobject newElement_2_slotIsPauseable; - if (!entry_2.slotIsPauseable.HasValue()) + jobject newElement_2_slotIsPausable; + if (!entry_2.slotIsPausable.HasValue()) { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_slotIsPauseable); + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_slotIsPausable); } else { - jobject newElement_2_slotIsPauseableInsideOptional; - std::string newElement_2_slotIsPauseableInsideOptionalClassName = "java/lang/Boolean"; - std::string newElement_2_slotIsPauseableInsideOptionalCtorSignature = "(Z)V"; - jboolean jninewElement_2_slotIsPauseableInsideOptional = - static_cast(entry_2.slotIsPauseable.Value()); + jobject newElement_2_slotIsPausableInsideOptional; + std::string newElement_2_slotIsPausableInsideOptionalClassName = "java/lang/Boolean"; + std::string newElement_2_slotIsPausableInsideOptionalCtorSignature = "(Z)V"; + jboolean jninewElement_2_slotIsPausableInsideOptional = + static_cast(entry_2.slotIsPausable.Value()); chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_slotIsPauseableInsideOptionalClassName.c_str(), - newElement_2_slotIsPauseableInsideOptionalCtorSignature.c_str(), - jninewElement_2_slotIsPauseableInsideOptional, newElement_2_slotIsPauseableInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_2_slotIsPauseableInsideOptional, - newElement_2_slotIsPauseable); + newElement_2_slotIsPausableInsideOptionalClassName.c_str(), + newElement_2_slotIsPausableInsideOptionalCtorSignature.c_str(), + jninewElement_2_slotIsPausableInsideOptional, newElement_2_slotIsPausableInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_slotIsPausableInsideOptional, + newElement_2_slotIsPausable); } jobject newElement_2_minPauseDuration; if (!entry_2.minPauseDuration.HasValue()) @@ -23976,7 +24015,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2 = env->NewObject( slotStructStructClass_3, slotStructStructCtor_3, newElement_2_minDuration, newElement_2_maxDuration, newElement_2_defaultDuration, newElement_2_elapsedSlotTime, newElement_2_remainingSlotTime, - newElement_2_slotIsPauseable, newElement_2_minPauseDuration, newElement_2_maxPauseDuration, + newElement_2_slotIsPausable, newElement_2_minPauseDuration, newElement_2_maxPauseDuration, newElement_2_manufacturerESAState, newElement_2_nominalPower, newElement_2_minPower, newElement_2_maxPower, newElement_2_nominalEnergy, newElement_2_costs, newElement_2_minPowerAdjustment, newElement_2_maxPowerAdjustment, newElement_2_minDurationAdjustment, newElement_2_maxDurationAdjustment); @@ -24003,7 +24042,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jmethodID forecastStructStructCtor_1; err = chip::JniReferences::GetInstance().FindMethod( env, forecastStructStructClass_1, "", - "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/" + "(Ljava/lang/Long;Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/" "Optional;Ljava/lang/Boolean;Ljava/util/ArrayList;Ljava/lang/Integer;)V", &forecastStructStructCtor_1); if (err != CHIP_NO_ERROR || forecastStructStructCtor_1 == nullptr) @@ -24012,9 +24051,9 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } - value = env->NewObject(forecastStructStructClass_1, forecastStructStructCtor_1, value_forecastId, + value = env->NewObject(forecastStructStructClass_1, forecastStructStructCtor_1, value_forecastID, value_activeSlotNumber, value_startTime, value_endTime, value_earliestStartTime, - value_latestEndTime, value_isPauseable, value_slots, value_forecastUpdateReason); + value_latestEndTime, value_isPausable, value_slots, value_forecastUpdateReason); } return value; } diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 24b35747203355..0a6bfd78f2194b 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -6829,7 +6829,7 @@ class ChipClusters: "commandId": 0x00000005, "commandName": "ModifyForecastRequest", "args": { - "forecastId": "int", + "forecastID": "int", "slotAdjustments": "SlotAdjustmentStruct", "cause": "int", }, diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 527bc943019cbb..c9cb62b4be021a 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -24138,7 +24138,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="ESAState", Tag=0x00000002, Type=DeviceEnergyManagement.Enums.ESAStateEnum), ClusterObjectFieldDescriptor(Label="absMinPower", Tag=0x00000003, Type=int), ClusterObjectFieldDescriptor(Label="absMaxPower", Tag=0x00000004, Type=int), - ClusterObjectFieldDescriptor(Label="powerAdjustmentCapability", Tag=0x00000005, Type=typing.Union[None, Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]), + ClusterObjectFieldDescriptor(Label="powerAdjustmentCapability", Tag=0x00000005, Type=typing.Union[None, Nullable, DeviceEnergyManagement.Structs.PowerAdjustCapabilityStruct]), ClusterObjectFieldDescriptor(Label="forecast", Tag=0x00000006, Type=typing.Union[None, Nullable, DeviceEnergyManagement.Structs.ForecastStruct]), ClusterObjectFieldDescriptor(Label="optOutState", Tag=0x00000007, Type=typing.Optional[DeviceEnergyManagement.Enums.OptOutStateEnum]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), @@ -24154,7 +24154,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ESAState: 'DeviceEnergyManagement.Enums.ESAStateEnum' = None absMinPower: 'int' = None absMaxPower: 'int' = None - powerAdjustmentCapability: 'typing.Union[None, Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]' = None + powerAdjustmentCapability: 'typing.Union[None, Nullable, DeviceEnergyManagement.Structs.PowerAdjustCapabilityStruct]' = None forecast: 'typing.Union[None, Nullable, DeviceEnergyManagement.Structs.ForecastStruct]' = None optOutState: 'typing.Optional[DeviceEnergyManagement.Enums.OptOutStateEnum]' = None generatedCommandList: 'typing.List[uint]' = None @@ -24252,6 +24252,16 @@ class OptOutStateEnum(MatterIntEnum): # enum value. This specific should never be transmitted. kUnknownEnumValue = 4, + class PowerAdjustReasonEnum(MatterIntEnum): + kNoAdjustment = 0x00 + kLocalOptimizationAdjustment = 0x01 + kGridOptimizationAdjustment = 0x02 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 3, + class Bitmaps: class Feature(IntFlag): kPowerAdjustment = 0x1 @@ -24280,6 +24290,36 @@ def descriptor(cls) -> ClusterObjectDescriptor: decimalPoints: 'uint' = 0 currency: 'typing.Optional[uint]' = None + @dataclass + class PowerAdjustStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="minPower", Tag=0, Type=int), + ClusterObjectFieldDescriptor(Label="maxPower", Tag=1, Type=int), + ClusterObjectFieldDescriptor(Label="minDuration", Tag=2, Type=uint), + ClusterObjectFieldDescriptor(Label="maxDuration", Tag=3, Type=uint), + ]) + + minPower: 'int' = 0 + maxPower: 'int' = 0 + minDuration: 'uint' = 0 + maxDuration: 'uint' = 0 + + @dataclass + class PowerAdjustCapabilityStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="powerAdjustCapability", Tag=0, Type=typing.Union[Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]), + ClusterObjectFieldDescriptor(Label="cause", Tag=1, Type=DeviceEnergyManagement.Enums.PowerAdjustReasonEnum), + ]) + + powerAdjustCapability: 'typing.Union[Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]' = NullValue + cause: 'DeviceEnergyManagement.Enums.PowerAdjustReasonEnum' = 0 + @dataclass class SlotStruct(ClusterObject): @ChipUtility.classproperty @@ -24291,7 +24331,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="defaultDuration", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="elapsedSlotTime", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="remainingSlotTime", Tag=4, Type=uint), - ClusterObjectFieldDescriptor(Label="slotIsPauseable", Tag=5, Type=typing.Optional[bool]), + ClusterObjectFieldDescriptor(Label="slotIsPausable", Tag=5, Type=typing.Optional[bool]), ClusterObjectFieldDescriptor(Label="minPauseDuration", Tag=6, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="maxPauseDuration", Tag=7, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="manufacturerESAState", Tag=8, Type=typing.Optional[uint]), @@ -24311,7 +24351,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: defaultDuration: 'uint' = 0 elapsedSlotTime: 'uint' = 0 remainingSlotTime: 'uint' = 0 - slotIsPauseable: 'typing.Optional[bool]' = None + slotIsPausable: 'typing.Optional[bool]' = None minPauseDuration: 'typing.Optional[uint]' = None maxPauseDuration: 'typing.Optional[uint]' = None manufacturerESAState: 'typing.Optional[uint]' = None @@ -24331,24 +24371,24 @@ class ForecastStruct(ClusterObject): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="forecastId", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="forecastID", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="activeSlotNumber", Tag=1, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="startTime", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="endTime", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="earliestStartTime", Tag=4, Type=typing.Union[None, Nullable, uint]), ClusterObjectFieldDescriptor(Label="latestEndTime", Tag=5, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="isPauseable", Tag=6, Type=bool), + ClusterObjectFieldDescriptor(Label="isPausable", Tag=6, Type=bool), ClusterObjectFieldDescriptor(Label="slots", Tag=7, Type=typing.List[DeviceEnergyManagement.Structs.SlotStruct]), ClusterObjectFieldDescriptor(Label="forecastUpdateReason", Tag=8, Type=DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum), ]) - forecastId: 'uint' = 0 + forecastID: 'uint' = 0 activeSlotNumber: 'typing.Union[Nullable, uint]' = NullValue startTime: 'uint' = 0 endTime: 'uint' = 0 earliestStartTime: 'typing.Union[None, Nullable, uint]' = None latestEndTime: 'typing.Optional[uint]' = None - isPauseable: 'bool' = False + isPausable: 'bool' = False slots: 'typing.List[DeviceEnergyManagement.Structs.SlotStruct]' = field(default_factory=lambda: []) forecastUpdateReason: 'DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum' = 0 @@ -24371,23 +24411,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: maximumEnergy: 'typing.Optional[int]' = None loadControl: 'typing.Optional[int]' = None - @dataclass - class PowerAdjustStruct(ClusterObject): - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ClusterObjectFieldDescriptor(Label="minPower", Tag=0, Type=int), - ClusterObjectFieldDescriptor(Label="maxPower", Tag=1, Type=int), - ClusterObjectFieldDescriptor(Label="minDuration", Tag=2, Type=uint), - ClusterObjectFieldDescriptor(Label="maxDuration", Tag=3, Type=uint), - ]) - - minPower: 'int' = 0 - maxPower: 'int' = 0 - minDuration: 'uint' = 0 - maxDuration: 'uint' = 0 - @dataclass class SlotAdjustmentStruct(ClusterObject): @ChipUtility.classproperty @@ -24395,12 +24418,12 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ ClusterObjectFieldDescriptor(Label="slotIndex", Tag=0, Type=uint), - ClusterObjectFieldDescriptor(Label="nominalPower", Tag=1, Type=int), + ClusterObjectFieldDescriptor(Label="nominalPower", Tag=1, Type=typing.Optional[int]), ClusterObjectFieldDescriptor(Label="duration", Tag=2, Type=uint), ]) slotIndex: 'uint' = 0 - nominalPower: 'int' = 0 + nominalPower: 'typing.Optional[int]' = None duration: 'uint' = 0 class Commands: @@ -24497,12 +24520,12 @@ class ModifyForecastRequest(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="forecastId", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="forecastID", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="slotAdjustments", Tag=1, Type=typing.List[DeviceEnergyManagement.Structs.SlotAdjustmentStruct]), ClusterObjectFieldDescriptor(Label="cause", Tag=2, Type=DeviceEnergyManagement.Enums.AdjustmentCauseEnum), ]) - forecastId: 'uint' = 0 + forecastID: 'uint' = 0 slotAdjustments: 'typing.List[DeviceEnergyManagement.Structs.SlotAdjustmentStruct]' = field(default_factory=lambda: []) cause: 'DeviceEnergyManagement.Enums.AdjustmentCauseEnum' = 0 @@ -24630,9 +24653,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, DeviceEnergyManagement.Structs.PowerAdjustCapabilityStruct]) - value: 'typing.Union[None, Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]' = None + value: 'typing.Union[None, Nullable, DeviceEnergyManagement.Structs.PowerAdjustCapabilityStruct]' = None @dataclass class Forecast(ClusterAttributeDescriptor): diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 9497069cb7e507..e13569d1a2b906 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -8904,30 +8904,36 @@ static id _Nullable DecodeAttributeValueForDeviceEnergyManagementCluster(Attribu if (*aError != CHIP_NO_ERROR) { return nil; } - NSArray * _Nullable value; + MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value; if (cppValue.IsNull()) { value = nil; } else { - { // Scope for our temporary variables - auto * array_1 = [NSMutableArray new]; - auto iter_1 = cppValue.Value().begin(); - while (iter_1.Next()) { - auto & entry_1 = iter_1.GetValue(); - MTRDeviceEnergyManagementClusterPowerAdjustStruct * newElement_1; - newElement_1 = [MTRDeviceEnergyManagementClusterPowerAdjustStruct new]; - newElement_1.minPower = [NSNumber numberWithLongLong:entry_1.minPower]; - newElement_1.maxPower = [NSNumber numberWithLongLong:entry_1.maxPower]; - newElement_1.minDuration = [NSNumber numberWithUnsignedInt:entry_1.minDuration]; - newElement_1.maxDuration = [NSNumber numberWithUnsignedInt:entry_1.maxDuration]; - [array_1 addObject:newElement_1]; - } - CHIP_ERROR err = iter_1.GetStatus(); - if (err != CHIP_NO_ERROR) { - *aError = err; - return nil; + value = [MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct new]; + if (cppValue.Value().powerAdjustCapability.IsNull()) { + value.powerAdjustCapability = nil; + } else { + { // Scope for our temporary variables + auto * array_3 = [NSMutableArray new]; + auto iter_3 = cppValue.Value().powerAdjustCapability.Value().begin(); + while (iter_3.Next()) { + auto & entry_3 = iter_3.GetValue(); + MTRDeviceEnergyManagementClusterPowerAdjustStruct * newElement_3; + newElement_3 = [MTRDeviceEnergyManagementClusterPowerAdjustStruct new]; + newElement_3.minPower = [NSNumber numberWithLongLong:entry_3.minPower]; + newElement_3.maxPower = [NSNumber numberWithLongLong:entry_3.maxPower]; + newElement_3.minDuration = [NSNumber numberWithUnsignedInt:entry_3.minDuration]; + newElement_3.maxDuration = [NSNumber numberWithUnsignedInt:entry_3.maxDuration]; + [array_3 addObject:newElement_3]; + } + CHIP_ERROR err = iter_3.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value.powerAdjustCapability = array_3; } - value = array_1; } + value.cause = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.Value().cause)]; } return value; } @@ -8943,7 +8949,7 @@ static id _Nullable DecodeAttributeValueForDeviceEnergyManagementCluster(Attribu value = nil; } else { value = [MTRDeviceEnergyManagementClusterForecastStruct new]; - value.forecastId = [NSNumber numberWithUnsignedShort:cppValue.Value().forecastId]; + value.forecastID = [NSNumber numberWithUnsignedInt:cppValue.Value().forecastID]; if (cppValue.Value().activeSlotNumber.IsNull()) { value.activeSlotNumber = nil; } else { @@ -8965,7 +8971,7 @@ static id _Nullable DecodeAttributeValueForDeviceEnergyManagementCluster(Attribu } else { value.latestEndTime = nil; } - value.isPauseable = [NSNumber numberWithBool:cppValue.Value().isPauseable]; + value.isPausable = [NSNumber numberWithBool:cppValue.Value().isPausable]; { // Scope for our temporary variables auto * array_2 = [NSMutableArray new]; auto iter_2 = cppValue.Value().slots.begin(); @@ -8978,10 +8984,10 @@ static id _Nullable DecodeAttributeValueForDeviceEnergyManagementCluster(Attribu newElement_2.defaultDuration = [NSNumber numberWithUnsignedInt:entry_2.defaultDuration]; newElement_2.elapsedSlotTime = [NSNumber numberWithUnsignedInt:entry_2.elapsedSlotTime]; newElement_2.remainingSlotTime = [NSNumber numberWithUnsignedInt:entry_2.remainingSlotTime]; - if (entry_2.slotIsPauseable.HasValue()) { - newElement_2.slotIsPauseable = [NSNumber numberWithBool:entry_2.slotIsPauseable.Value()]; + if (entry_2.slotIsPausable.HasValue()) { + newElement_2.slotIsPausable = [NSNumber numberWithBool:entry_2.slotIsPausable.Value()]; } else { - newElement_2.slotIsPauseable = nil; + newElement_2.slotIsPausable = nil; } if (entry_2.minPauseDuration.HasValue()) { newElement_2.minPauseDuration = [NSNumber numberWithUnsignedInt:entry_2.minPauseDuration.Value()]; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c5e73b22368081..2dc04b9623a652 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -7827,11 +7827,11 @@ MTR_PROVISIONALLY_AVAILABLE reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; + (void)readAttributeAbsMaxPowerWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; -- (void)readAttributePowerAdjustmentCapabilityWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)readAttributePowerAdjustmentCapabilityWithCompletion:(void (^)(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)subscribeAttributePowerAdjustmentCapabilityWithParams:(MTRSubscribeParams *)params subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished - reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; -+ (void)readAttributePowerAdjustmentCapabilityWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + reportHandler:(void (^)(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributePowerAdjustmentCapabilityWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)readAttributeForecastWithCompletion:(void (^)(MTRDeviceEnergyManagementClusterForecastStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)subscribeAttributeForecastWithParams:(MTRSubscribeParams *)params @@ -18143,6 +18143,12 @@ typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementOptOutState) { MTRDeviceEnergyManagementOptOutStateOptOut MTR_PROVISIONALLY_AVAILABLE = 0x03, } MTR_PROVISIONALLY_AVAILABLE; +typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementPowerAdjustReason) { + MTRDeviceEnergyManagementPowerAdjustReasonNoAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRDeviceEnergyManagementPowerAdjustReasonLocalOptimizationAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x01, + MTRDeviceEnergyManagementPowerAdjustReasonGridOptimizationAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x02, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_OPTIONS(uint32_t, MTRDeviceEnergyManagementFeature) { MTRDeviceEnergyManagementFeaturePowerAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x1, MTRDeviceEnergyManagementFeaturePowerForecastReporting 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 1df39709657551..5d7e8e691bac62 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -52502,7 +52502,7 @@ + (void)readAttributeAbsMaxPowerWithClusterStateCache:(MTRClusterStateCacheConta completion:completion]; } -- (void)readAttributePowerAdjustmentCapabilityWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +- (void)readAttributePowerAdjustmentCapabilityWithCompletion:(void (^)(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error))completion { using TypeInfo = DeviceEnergyManagement::Attributes::PowerAdjustmentCapability::TypeInfo; [self.device _readKnownAttributeWithEndpointID:self.endpointID @@ -52515,7 +52515,7 @@ - (void)readAttributePowerAdjustmentCapabilityWithCompletion:(void (^)(NSArray * - (void)subscribeAttributePowerAdjustmentCapabilityWithParams:(MTRSubscribeParams * _Nonnull)params subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished - reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler + reportHandler:(void (^)(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error))reportHandler { using TypeInfo = DeviceEnergyManagement::Attributes::PowerAdjustmentCapability::TypeInfo; [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID @@ -52527,7 +52527,7 @@ - (void)subscribeAttributePowerAdjustmentCapabilityWithParams:(MTRSubscribeParam subscriptionEstablished:subscriptionEstablished]; } -+ (void)readAttributePowerAdjustmentCapabilityWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion ++ (void)readAttributePowerAdjustmentCapabilityWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error))completion { using TypeInfo = DeviceEnergyManagement::Attributes::PowerAdjustmentCapability::TypeInfo; [clusterStateCacheContainer diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 0017193f50a673..51b679e5ed5afd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -5739,7 +5739,7 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterModifyForecastRequestParams : NSObject -@property (nonatomic, copy) NSNumber * _Nonnull forecastId MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull forecastID MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSArray * _Nonnull slotAdjustments MTR_PROVISIONALLY_AVAILABLE; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 689b7382ab3fb5..0af42978861dd7 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -16113,7 +16113,7 @@ - (instancetype)init { if (self = [super init]) { - _forecastId = @(0); + _forecastID = @(0); _slotAdjustments = [NSArray array]; @@ -16128,7 +16128,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; { auto other = [[MTRDeviceEnergyManagementClusterModifyForecastRequestParams alloc] init]; - other.forecastId = self.forecastId; + other.forecastID = self.forecastID; other.slotAdjustments = self.slotAdjustments; other.cause = self.cause; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; @@ -16139,7 +16139,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastId:%@; slotAdjustments:%@; cause:%@; >", NSStringFromClass([self class]), _forecastId, _slotAdjustments, _cause]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastID:%@; slotAdjustments:%@; cause:%@; >", NSStringFromClass([self class]), _forecastID, _slotAdjustments, _cause]; return descriptionString; } @@ -16152,7 +16152,7 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader chip::app::Clusters::DeviceEnergyManagement::Commands::ModifyForecastRequest::Type encodableStruct; ListFreer listFreer; { - encodableStruct.forecastId = self.forecastId.unsignedIntValue; + encodableStruct.forecastID = self.forecastID.unsignedIntValue; } { { @@ -16171,7 +16171,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader } auto element_0 = (MTRDeviceEnergyManagementClusterSlotAdjustmentStruct *) self.slotAdjustments[i_0]; listHolder_0->mList[i_0].slotIndex = element_0.slotIndex.unsignedCharValue; - listHolder_0->mList[i_0].nominalPower = element_0.nominalPower.longLongValue; + if (element_0.nominalPower != nil) { + auto & definedValue_2 = listHolder_0->mList[i_0].nominalPower.Emplace(); + definedValue_2 = element_0.nominalPower.longLongValue; + } listHolder_0->mList[i_0].duration = element_0.duration.unsignedIntValue; } encodableStruct.slotAdjustments = ListType_0(listHolder_0->mList, self.slotAdjustments.count); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index e4d9eb08566a50..5729c811ab2ac4 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1285,6 +1285,20 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nullable currency MTR_PROVISIONALLY_AVAILABLE; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRDeviceEnergyManagementClusterPowerAdjustStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull minPower MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull maxPower MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull minDuration MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull maxDuration MTR_PROVISIONALLY_AVAILABLE; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct : NSObject +@property (nonatomic, copy) NSArray * _Nullable powerAdjustCapability MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull cause MTR_PROVISIONALLY_AVAILABLE; +@end + MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterSlotStruct : NSObject @property (nonatomic, copy) NSNumber * _Nonnull minDuration MTR_PROVISIONALLY_AVAILABLE; @@ -1292,7 +1306,7 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nonnull defaultDuration MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull elapsedSlotTime MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull remainingSlotTime MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nullable slotIsPauseable MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable slotIsPausable MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable minPauseDuration MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable maxPauseDuration MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable manufacturerESAState MTR_PROVISIONALLY_AVAILABLE; @@ -1309,13 +1323,13 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterForecastStruct : NSObject -@property (nonatomic, copy) NSNumber * _Nonnull forecastId MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull forecastID MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable activeSlotNumber MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull startTime MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull endTime MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable earliestStartTime MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable latestEndTime MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull isPauseable MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull isPausable MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSArray * _Nonnull slots MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull forecastUpdateReason MTR_PROVISIONALLY_AVAILABLE; @end @@ -1329,18 +1343,10 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nullable loadControl MTR_PROVISIONALLY_AVAILABLE; @end -MTR_PROVISIONALLY_AVAILABLE -@interface MTRDeviceEnergyManagementClusterPowerAdjustStruct : NSObject -@property (nonatomic, copy) NSNumber * _Nonnull minPower MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull maxPower MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull minDuration MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull maxDuration MTR_PROVISIONALLY_AVAILABLE; -@end - MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterSlotAdjustmentStruct : NSObject @property (nonatomic, copy) NSNumber * _Nonnull slotIndex MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull nominalPower MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable nominalPower MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull duration MTR_PROVISIONALLY_AVAILABLE; @end diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 30c3531c6d7668..6f9a82e6231831 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -5251,6 +5251,72 @@ - (NSString *)description @end +@implementation MTRDeviceEnergyManagementClusterPowerAdjustStruct +- (instancetype)init +{ + if (self = [super init]) { + + _minPower = @(0); + + _maxPower = @(0); + + _minDuration = @(0); + + _maxDuration = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRDeviceEnergyManagementClusterPowerAdjustStruct alloc] init]; + + other.minPower = self.minPower; + other.maxPower = self.maxPower; + other.minDuration = self.minDuration; + other.maxDuration = self.maxDuration; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: minPower:%@; maxPower:%@; minDuration:%@; maxDuration:%@; >", NSStringFromClass([self class]), _minPower, _maxPower, _minDuration, _maxDuration]; + return descriptionString; +} + +@end + +@implementation MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct +- (instancetype)init +{ + if (self = [super init]) { + + _powerAdjustCapability = nil; + + _cause = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct alloc] init]; + + other.powerAdjustCapability = self.powerAdjustCapability; + other.cause = self.cause; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: powerAdjustCapability:%@; cause:%@; >", NSStringFromClass([self class]), _powerAdjustCapability, _cause]; + return descriptionString; +} + +@end + @implementation MTRDeviceEnergyManagementClusterSlotStruct - (instancetype)init { @@ -5266,7 +5332,7 @@ - (instancetype)init _remainingSlotTime = @(0); - _slotIsPauseable = nil; + _slotIsPausable = nil; _minPauseDuration = nil; @@ -5304,7 +5370,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone other.defaultDuration = self.defaultDuration; other.elapsedSlotTime = self.elapsedSlotTime; other.remainingSlotTime = self.remainingSlotTime; - other.slotIsPauseable = self.slotIsPauseable; + other.slotIsPausable = self.slotIsPausable; other.minPauseDuration = self.minPauseDuration; other.maxPauseDuration = self.maxPauseDuration; other.manufacturerESAState = self.manufacturerESAState; @@ -5323,7 +5389,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: minDuration:%@; maxDuration:%@; defaultDuration:%@; elapsedSlotTime:%@; remainingSlotTime:%@; slotIsPauseable:%@; minPauseDuration:%@; maxPauseDuration:%@; manufacturerESAState:%@; nominalPower:%@; minPower:%@; maxPower:%@; nominalEnergy:%@; costs:%@; minPowerAdjustment:%@; maxPowerAdjustment:%@; minDurationAdjustment:%@; maxDurationAdjustment:%@; >", NSStringFromClass([self class]), _minDuration, _maxDuration, _defaultDuration, _elapsedSlotTime, _remainingSlotTime, _slotIsPauseable, _minPauseDuration, _maxPauseDuration, _manufacturerESAState, _nominalPower, _minPower, _maxPower, _nominalEnergy, _costs, _minPowerAdjustment, _maxPowerAdjustment, _minDurationAdjustment, _maxDurationAdjustment]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: minDuration:%@; maxDuration:%@; defaultDuration:%@; elapsedSlotTime:%@; remainingSlotTime:%@; slotIsPausable:%@; minPauseDuration:%@; maxPauseDuration:%@; manufacturerESAState:%@; nominalPower:%@; minPower:%@; maxPower:%@; nominalEnergy:%@; costs:%@; minPowerAdjustment:%@; maxPowerAdjustment:%@; minDurationAdjustment:%@; maxDurationAdjustment:%@; >", NSStringFromClass([self class]), _minDuration, _maxDuration, _defaultDuration, _elapsedSlotTime, _remainingSlotTime, _slotIsPausable, _minPauseDuration, _maxPauseDuration, _manufacturerESAState, _nominalPower, _minPower, _maxPower, _nominalEnergy, _costs, _minPowerAdjustment, _maxPowerAdjustment, _minDurationAdjustment, _maxDurationAdjustment]; return descriptionString; } @@ -5334,7 +5400,7 @@ - (instancetype)init { if (self = [super init]) { - _forecastId = @(0); + _forecastID = @(0); _activeSlotNumber = nil; @@ -5346,7 +5412,7 @@ - (instancetype)init _latestEndTime = nil; - _isPauseable = @(0); + _isPausable = @(0); _slots = [NSArray array]; @@ -5359,13 +5425,13 @@ - (id)copyWithZone:(NSZone * _Nullable)zone { auto other = [[MTRDeviceEnergyManagementClusterForecastStruct alloc] init]; - other.forecastId = self.forecastId; + other.forecastID = self.forecastID; other.activeSlotNumber = self.activeSlotNumber; other.startTime = self.startTime; other.endTime = self.endTime; other.earliestStartTime = self.earliestStartTime; other.latestEndTime = self.latestEndTime; - other.isPauseable = self.isPauseable; + other.isPausable = self.isPausable; other.slots = self.slots; other.forecastUpdateReason = self.forecastUpdateReason; @@ -5374,7 +5440,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastId:%@; activeSlotNumber:%@; startTime:%@; endTime:%@; earliestStartTime:%@; latestEndTime:%@; isPauseable:%@; slots:%@; forecastUpdateReason:%@; >", NSStringFromClass([self class]), _forecastId, _activeSlotNumber, _startTime, _endTime, _earliestStartTime, _latestEndTime, _isPauseable, _slots, _forecastUpdateReason]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastID:%@; activeSlotNumber:%@; startTime:%@; endTime:%@; earliestStartTime:%@; latestEndTime:%@; isPausable:%@; slots:%@; forecastUpdateReason:%@; >", NSStringFromClass([self class]), _forecastID, _activeSlotNumber, _startTime, _endTime, _earliestStartTime, _latestEndTime, _isPausable, _slots, _forecastUpdateReason]; return descriptionString; } @@ -5419,42 +5485,6 @@ - (NSString *)description @end -@implementation MTRDeviceEnergyManagementClusterPowerAdjustStruct -- (instancetype)init -{ - if (self = [super init]) { - - _minPower = @(0); - - _maxPower = @(0); - - _minDuration = @(0); - - _maxDuration = @(0); - } - return self; -} - -- (id)copyWithZone:(NSZone * _Nullable)zone -{ - auto other = [[MTRDeviceEnergyManagementClusterPowerAdjustStruct alloc] init]; - - other.minPower = self.minPower; - other.maxPower = self.maxPower; - other.minDuration = self.minDuration; - other.maxDuration = self.maxDuration; - - return other; -} - -- (NSString *)description -{ - NSString * descriptionString = [NSString stringWithFormat:@"<%@: minPower:%@; maxPower:%@; minDuration:%@; maxDuration:%@; >", NSStringFromClass([self class]), _minPower, _maxPower, _minDuration, _maxDuration]; - return descriptionString; -} - -@end - @implementation MTRDeviceEnergyManagementClusterSlotAdjustmentStruct - (instancetype)init { @@ -5462,7 +5492,7 @@ - (instancetype)init _slotIndex = @(0); - _nominalPower = @(0); + _nominalPower = nil; _duration = @(0); } 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 ca25c08c748e0c..4ff889fac693cd 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 @@ -1767,6 +1767,19 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: return EnumType::kUnknownEnumValue; } } +static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::PowerAdjustReasonEnum val) +{ + using EnumType = DeviceEnergyManagement::PowerAdjustReasonEnum; + switch (val) + { + case EnumType::kNoAdjustment: + case EnumType::kLocalOptimizationAdjustment: + case EnumType::kGridOptimizationAdjustment: + return val; + default: + return EnumType::kUnknownEnumValue; + } +} static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::EnergyTransferStoppedReasonEnum val) { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index df8ddd16ba31e3..c0defa3c3fa360 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 @@ -2571,6 +2571,19 @@ enum class OptOutStateEnum : uint8_t kUnknownEnumValue = 4, }; +// Enum for PowerAdjustReasonEnum +enum class PowerAdjustReasonEnum : uint8_t +{ + kNoAdjustment = 0x00, + kLocalOptimizationAdjustment = 0x01, + kGridOptimizationAdjustment = 0x02, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 3, +}; + // Bitmap for Feature enum class Feature : uint32_t { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 0e3ec1d0347e1f..a4fa58609c345a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -15598,6 +15598,98 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace CostStruct +namespace PowerAdjustStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kMinPower), minPower); + encoder.Encode(to_underlying(Fields::kMaxPower), maxPower); + encoder.Encode(to_underlying(Fields::kMinDuration), minDuration); + encoder.Encode(to_underlying(Fields::kMaxDuration), maxDuration); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kMinPower)) + { + err = DataModel::Decode(reader, minPower); + } + else if (__context_tag == to_underlying(Fields::kMaxPower)) + { + err = DataModel::Decode(reader, maxPower); + } + else if (__context_tag == to_underlying(Fields::kMinDuration)) + { + err = DataModel::Decode(reader, minDuration); + } + else if (__context_tag == to_underlying(Fields::kMaxDuration)) + { + err = DataModel::Decode(reader, maxDuration); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} + +} // namespace PowerAdjustStruct + +namespace PowerAdjustCapabilityStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kPowerAdjustCapability), powerAdjustCapability); + encoder.Encode(to_underlying(Fields::kCause), cause); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kPowerAdjustCapability)) + { + err = DataModel::Decode(reader, powerAdjustCapability); + } + else if (__context_tag == to_underlying(Fields::kCause)) + { + err = DataModel::Decode(reader, cause); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} + +} // namespace PowerAdjustCapabilityStruct + namespace SlotStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { @@ -15607,7 +15699,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const encoder.Encode(to_underlying(Fields::kDefaultDuration), defaultDuration); encoder.Encode(to_underlying(Fields::kElapsedSlotTime), elapsedSlotTime); encoder.Encode(to_underlying(Fields::kRemainingSlotTime), remainingSlotTime); - encoder.Encode(to_underlying(Fields::kSlotIsPauseable), slotIsPauseable); + encoder.Encode(to_underlying(Fields::kSlotIsPausable), slotIsPausable); encoder.Encode(to_underlying(Fields::kMinPauseDuration), minPauseDuration); encoder.Encode(to_underlying(Fields::kMaxPauseDuration), maxPauseDuration); encoder.Encode(to_underlying(Fields::kManufacturerESAState), manufacturerESAState); @@ -15657,9 +15749,9 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, remainingSlotTime); } - else if (__context_tag == to_underlying(Fields::kSlotIsPauseable)) + else if (__context_tag == to_underlying(Fields::kSlotIsPausable)) { - err = DataModel::Decode(reader, slotIsPauseable); + err = DataModel::Decode(reader, slotIsPausable); } else if (__context_tag == to_underlying(Fields::kMinPauseDuration)) { @@ -15723,13 +15815,13 @@ namespace ForecastStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - encoder.Encode(to_underlying(Fields::kForecastId), forecastId); + encoder.Encode(to_underlying(Fields::kForecastID), forecastID); encoder.Encode(to_underlying(Fields::kActiveSlotNumber), activeSlotNumber); encoder.Encode(to_underlying(Fields::kStartTime), startTime); encoder.Encode(to_underlying(Fields::kEndTime), endTime); encoder.Encode(to_underlying(Fields::kEarliestStartTime), earliestStartTime); encoder.Encode(to_underlying(Fields::kLatestEndTime), latestEndTime); - encoder.Encode(to_underlying(Fields::kIsPauseable), isPauseable); + encoder.Encode(to_underlying(Fields::kIsPausable), isPausable); encoder.Encode(to_underlying(Fields::kSlots), slots); encoder.Encode(to_underlying(Fields::kForecastUpdateReason), forecastUpdateReason); return encoder.Finalize(); @@ -15749,9 +15841,9 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) CHIP_ERROR err = CHIP_NO_ERROR; const uint8_t __context_tag = std::get(__element); - if (__context_tag == to_underlying(Fields::kForecastId)) + if (__context_tag == to_underlying(Fields::kForecastID)) { - err = DataModel::Decode(reader, forecastId); + err = DataModel::Decode(reader, forecastID); } else if (__context_tag == to_underlying(Fields::kActiveSlotNumber)) { @@ -15773,9 +15865,9 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, latestEndTime); } - else if (__context_tag == to_underlying(Fields::kIsPauseable)) + else if (__context_tag == to_underlying(Fields::kIsPausable)) { - err = DataModel::Decode(reader, isPauseable); + err = DataModel::Decode(reader, isPausable); } else if (__context_tag == to_underlying(Fields::kSlots)) { @@ -15851,57 +15943,6 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace ConstraintsStruct -namespace PowerAdjustStruct { -CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const -{ - DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - encoder.Encode(to_underlying(Fields::kMinPower), minPower); - encoder.Encode(to_underlying(Fields::kMaxPower), maxPower); - encoder.Encode(to_underlying(Fields::kMinDuration), minDuration); - encoder.Encode(to_underlying(Fields::kMaxDuration), maxDuration); - return encoder.Finalize(); -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - detail::StructDecodeIterator __iterator(reader); - while (true) - { - auto __element = __iterator.Next(); - if (std::holds_alternative(__element)) - { - return std::get(__element); - } - - CHIP_ERROR err = CHIP_NO_ERROR; - const uint8_t __context_tag = std::get(__element); - - if (__context_tag == to_underlying(Fields::kMinPower)) - { - err = DataModel::Decode(reader, minPower); - } - else if (__context_tag == to_underlying(Fields::kMaxPower)) - { - err = DataModel::Decode(reader, maxPower); - } - else if (__context_tag == to_underlying(Fields::kMinDuration)) - { - err = DataModel::Decode(reader, minDuration); - } - else if (__context_tag == to_underlying(Fields::kMaxDuration)) - { - err = DataModel::Decode(reader, maxDuration); - } - else - { - } - - ReturnErrorOnFailure(err); - } -} - -} // namespace PowerAdjustStruct - namespace SlotAdjustmentStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { @@ -16116,7 +16157,7 @@ namespace ModifyForecastRequest { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - encoder.Encode(to_underlying(Fields::kForecastId), forecastId); + encoder.Encode(to_underlying(Fields::kForecastID), forecastID); encoder.Encode(to_underlying(Fields::kSlotAdjustments), slotAdjustments); encoder.Encode(to_underlying(Fields::kCause), cause); return encoder.Finalize(); @@ -16136,9 +16177,9 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) CHIP_ERROR err = CHIP_NO_ERROR; const uint8_t __context_tag = std::get(__element); - if (__context_tag == to_underlying(Fields::kForecastId)) + if (__context_tag == to_underlying(Fields::kForecastID)) { - err = DataModel::Decode(reader, forecastId); + err = DataModel::Decode(reader, forecastID); } else if (__context_tag == to_underlying(Fields::kSlotAdjustments)) { 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 65450ac4489324..ff80ff45fc809f 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 @@ -21861,6 +21861,63 @@ struct Type using DecodableType = Type; } // namespace CostStruct +namespace PowerAdjustStruct { +enum class Fields : uint8_t +{ + kMinPower = 0, + kMaxPower = 1, + kMinDuration = 2, + kMaxDuration = 3, +}; + +struct Type +{ +public: + int64_t minPower = static_cast(0); + int64_t maxPower = static_cast(0); + uint32_t minDuration = static_cast(0); + uint32_t maxDuration = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +using DecodableType = Type; + +} // namespace PowerAdjustStruct +namespace PowerAdjustCapabilityStruct { +enum class Fields : uint8_t +{ + kPowerAdjustCapability = 0, + kCause = 1, +}; + +struct Type +{ +public: + DataModel::Nullable> powerAdjustCapability; + PowerAdjustReasonEnum cause = static_cast(0); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +struct DecodableType +{ +public: + DataModel::Nullable> powerAdjustCapability; + PowerAdjustReasonEnum cause = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; +}; + +} // namespace PowerAdjustCapabilityStruct namespace SlotStruct { enum class Fields : uint8_t { @@ -21869,7 +21926,7 @@ enum class Fields : uint8_t kDefaultDuration = 2, kElapsedSlotTime = 3, kRemainingSlotTime = 4, - kSlotIsPauseable = 5, + kSlotIsPausable = 5, kMinPauseDuration = 6, kMaxPauseDuration = 7, kManufacturerESAState = 8, @@ -21892,7 +21949,7 @@ struct Type uint32_t defaultDuration = static_cast(0); uint32_t elapsedSlotTime = static_cast(0); uint32_t remainingSlotTime = static_cast(0); - Optional slotIsPauseable; + Optional slotIsPausable; Optional minPauseDuration; Optional maxPauseDuration; Optional manufacturerESAState; @@ -21919,7 +21976,7 @@ struct DecodableType uint32_t defaultDuration = static_cast(0); uint32_t elapsedSlotTime = static_cast(0); uint32_t remainingSlotTime = static_cast(0); - Optional slotIsPauseable; + Optional slotIsPausable; Optional minPauseDuration; Optional maxPauseDuration; Optional manufacturerESAState; @@ -21942,13 +21999,13 @@ struct DecodableType namespace ForecastStruct { enum class Fields : uint8_t { - kForecastId = 0, + kForecastID = 0, kActiveSlotNumber = 1, kStartTime = 2, kEndTime = 3, kEarliestStartTime = 4, kLatestEndTime = 5, - kIsPauseable = 6, + kIsPausable = 6, kSlots = 7, kForecastUpdateReason = 8, }; @@ -21956,13 +22013,13 @@ enum class Fields : uint8_t struct Type { public: - uint16_t forecastId = static_cast(0); + uint32_t forecastID = static_cast(0); DataModel::Nullable activeSlotNumber; uint32_t startTime = static_cast(0); uint32_t endTime = static_cast(0); Optional> earliestStartTime; Optional latestEndTime; - bool isPauseable = static_cast(0); + bool isPausable = static_cast(0); DataModel::List slots; ForecastUpdateReasonEnum forecastUpdateReason = static_cast(0); @@ -21974,13 +22031,13 @@ struct Type struct DecodableType { public: - uint16_t forecastId = static_cast(0); + uint32_t forecastID = static_cast(0); DataModel::Nullable activeSlotNumber; uint32_t startTime = static_cast(0); uint32_t endTime = static_cast(0); Optional> earliestStartTime; Optional latestEndTime; - bool isPauseable = static_cast(0); + bool isPausable = static_cast(0); DataModel::DecodableList slots; ForecastUpdateReasonEnum forecastUpdateReason = static_cast(0); @@ -22019,33 +22076,6 @@ struct Type using DecodableType = Type; } // namespace ConstraintsStruct -namespace PowerAdjustStruct { -enum class Fields : uint8_t -{ - kMinPower = 0, - kMaxPower = 1, - kMinDuration = 2, - kMaxDuration = 3, -}; - -struct Type -{ -public: - int64_t minPower = static_cast(0); - int64_t maxPower = static_cast(0); - uint32_t minDuration = static_cast(0); - uint32_t maxDuration = static_cast(0); - - CHIP_ERROR Decode(TLV::TLVReader & reader); - - static constexpr bool kIsFabricScoped = false; - - CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; -}; - -using DecodableType = Type; - -} // namespace PowerAdjustStruct namespace SlotAdjustmentStruct { enum class Fields : uint8_t { @@ -22057,9 +22087,9 @@ enum class Fields : uint8_t struct Type { public: - uint8_t slotIndex = static_cast(0); - int64_t nominalPower = static_cast(0); - uint32_t duration = static_cast(0); + uint8_t slotIndex = static_cast(0); + Optional nominalPower; + uint32_t duration = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -22286,7 +22316,7 @@ struct DecodableType namespace ModifyForecastRequest { enum class Fields : uint8_t { - kForecastId = 0, + kForecastID = 0, kSlotAdjustments = 1, kCause = 2, }; @@ -22298,7 +22328,7 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::ModifyForecastRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } - uint32_t forecastId = static_cast(0); + uint32_t forecastID = static_cast(0); DataModel::List slotAdjustments; AdjustmentCauseEnum cause = static_cast(0); @@ -22315,7 +22345,7 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::ModifyForecastRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } - uint32_t forecastId = static_cast(0); + uint32_t forecastID = static_cast(0); DataModel::DecodableList slotAdjustments; AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -22451,12 +22481,12 @@ struct TypeInfo namespace PowerAdjustmentCapability { struct TypeInfo { - using Type = chip::app::DataModel::Nullable< - chip::app::DataModel::List>; - using DecodableType = chip::app::DataModel::Nullable>; - using DecodableArgType = const chip::app::DataModel::Nullable> &; + using Type = + chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable< + chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::DecodableType>; + using DecodableArgType = const chip::app::DataModel::Nullable< + chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::DecodableType> &; static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::PowerAdjustmentCapability::Id; } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 6552c1be593c49..991df28aee11ef 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -7150,7 +7150,7 @@ class DeviceEnergyManagementModifyForecastRequest : public ClusterCommand DeviceEnergyManagementModifyForecastRequest(CredentialIssuerCommands * credsIssuerConfig) : ClusterCommand("modify-forecast-request", credsIssuerConfig), mComplex_SlotAdjustments(&mRequest.slotAdjustments) { - AddArgument("ForecastId", 0, UINT32_MAX, &mRequest.forecastId); + AddArgument("ForecastID", 0, UINT32_MAX, &mRequest.forecastID); AddArgument("SlotAdjustments", &mComplex_SlotAdjustments); AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); ClusterCommand::AddArguments(); @@ -20794,7 +20794,7 @@ void registerClusterDeviceEnergyManagement(Commands & commands, CredentialIssuer make_unique>(Id, "abs-max-power", INT64_MIN, INT64_MAX, Attributes::AbsMaxPower::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>>( + chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::Type>>>( Id, "power-adjustment-capability", Attributes::PowerAdjustmentCapability::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique> + chip::app::DataModel::Nullable< + chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::DecodableType> value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("PowerAdjustmentCapability", 1, value); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index 5a562d72f6fd08..c243dc53db667d 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -236,6 +236,13 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DeviceEnergyManagement::Structs::CostStruct::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustStruct::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DeviceEnergyManagement::Structs::SlotStruct::DecodableType & value); @@ -245,9 +252,6 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DeviceEnergyManagement::Structs::ConstraintsStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustStruct::DecodableType & value); - static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DeviceEnergyManagement::Structs::SlotAdjustmentStruct::DecodableType & value); diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 92f8095b738474..db6ac867da715b 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -81845,7 +81845,7 @@ class DeviceEnergyManagementModifyForecastRequest : public ClusterCommand { , mComplex_SlotAdjustments(&mRequest.slotAdjustments) { #if MTR_ENABLE_PROVISIONAL - AddArgument("ForecastId", 0, UINT32_MAX, &mRequest.forecastId); + AddArgument("ForecastID", 0, UINT32_MAX, &mRequest.forecastID); #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL AddArgument("SlotAdjustments", &mComplex_SlotAdjustments); @@ -81868,7 +81868,7 @@ class DeviceEnergyManagementModifyForecastRequest : public ClusterCommand { __auto_type * params = [[MTRDeviceEnergyManagementClusterModifyForecastRequestParams alloc] init]; params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; #if MTR_ENABLE_PROVISIONAL - params.forecastId = [NSNumber numberWithUnsignedInt:mRequest.forecastId]; + params.forecastID = [NSNumber numberWithUnsignedInt:mRequest.forecastID]; #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL { // Scope for our temporary variables @@ -81877,7 +81877,11 @@ class DeviceEnergyManagementModifyForecastRequest : public ClusterCommand { MTRDeviceEnergyManagementClusterSlotAdjustmentStruct * newElement_0; newElement_0 = [MTRDeviceEnergyManagementClusterSlotAdjustmentStruct new]; newElement_0.slotIndex = [NSNumber numberWithUnsignedChar:entry_0.slotIndex]; - newElement_0.nominalPower = [NSNumber numberWithLongLong:entry_0.nominalPower]; + if (entry_0.nominalPower.HasValue()) { + newElement_0.nominalPower = [NSNumber numberWithLongLong:entry_0.nominalPower.Value()]; + } else { + newElement_0.nominalPower = nil; + } newElement_0.duration = [NSNumber numberWithUnsignedInt:entry_0.duration]; [array_0 addObject:newElement_0]; } @@ -82495,7 +82499,7 @@ class ReadDeviceEnergyManagementPowerAdjustmentCapability : public ReadAttribute dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); __auto_type * cluster = [[MTRBaseClusterDeviceEnergyManagement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; - [cluster readAttributePowerAdjustmentCapabilityWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + [cluster readAttributePowerAdjustmentCapabilityWithCompletion:^(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error) { NSLog(@"DeviceEnergyManagement.PowerAdjustmentCapability response %@", [value description]); if (error == nil) { RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); @@ -82540,7 +82544,7 @@ class SubscribeAttributeDeviceEnergyManagementPowerAdjustmentCapability : public } [cluster subscribeAttributePowerAdjustmentCapabilityWithParams:params subscriptionEstablished:^() { mSubscriptionEstablished = YES; } - reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + reportHandler:^(MTRDeviceEnergyManagementClusterPowerAdjustCapabilityStruct * _Nullable value, NSError * _Nullable error) { NSLog(@"DeviceEnergyManagement.PowerAdjustmentCapability response %@", [value description]); if (error == nil) { RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); From 9931b0a42d55c337475a5dba5a8ac693afe75d9b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 6 Jun 2024 09:15:49 +0000 Subject: [PATCH 2/6] Restyled by clang-format --- .../device-energy-management-server.cpp | 13 ++++++------- .../device-energy-management-server.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp index 2b42c74369cdcd..8e609813012024 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp @@ -324,7 +324,8 @@ void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::Po return; } - DataModel::Nullable powerAdjustmentCapabilityStruct = mDelegate.GetPowerAdjustmentCapability(); + DataModel::Nullable powerAdjustmentCapabilityStruct = + mDelegate.GetPowerAdjustmentCapability(); if (powerAdjustmentCapabilityStruct.IsNull()) { ChipLogError(Zcl, "DEM: powerAdjustmentCapabilityStruct IsNull"); @@ -693,8 +694,7 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: // NominalPower is only relevant if PFR is supported if (HasFeature(Feature::kPowerForecastReporting)) { - if (!slot.minPowerAdjustment.HasValue() || - !slot.maxPowerAdjustment.HasValue() || + if (!slot.minPowerAdjustment.HasValue() || !slot.maxPowerAdjustment.HasValue() || slotAdjustment.nominalPower.Value() < slot.minPowerAdjustment.Value() || slotAdjustment.nominalPower.Value() > slot.maxPowerAdjustment.Value()) { @@ -704,8 +704,7 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: } } - if (!slot.minDurationAdjustment.HasValue() || - !slot.maxDurationAdjustment.HasValue() || + if (!slot.minDurationAdjustment.HasValue() || !slot.maxDurationAdjustment.HasValue() || slotAdjustment.duration < slot.minDurationAdjustment.Value() || slotAdjustment.duration > slot.maxDurationAdjustment.Value()) { @@ -748,7 +747,7 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, } uint32_t currentUtcTime = 0; - status = GetCurrentUtcTime(currentUtcTime); + status = GetCurrentUtcTime(currentUtcTime); if (status != Status::Success) { ChipLogError(Zcl, "DEM: Forecast is Null"); @@ -848,7 +847,7 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, void Instance::HandleCancelRequest(HandlerContext & ctx, const Commands::CancelRequest::DecodableType & commandData) { - Status status = Status::Failure; + Status status = Status::Failure; DataModel::Nullable forecast = mDelegate.GetForecast(); if (forecast.IsNull()) diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.h b/src/app/clusters/device-energy-management-server/device-energy-management-server.h index 7557871f48c3dd..cad3abc3db5a92 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.h +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.h @@ -174,7 +174,7 @@ class Delegate virtual CHIP_ERROR SetESAType(ESATypeEnum) = 0; virtual CHIP_ERROR SetESACanGenerate(bool) = 0; virtual CHIP_ERROR SetESAState(ESAStateEnum) = 0; - virtual CHIP_ERROR SetAbsMinPower(int64_t) = 0 ; + virtual CHIP_ERROR SetAbsMinPower(int64_t) = 0; virtual CHIP_ERROR SetAbsMaxPower(int64_t) = 0; virtual CHIP_ERROR SetPowerAdjustmentCapability(DataModel::Nullable) = 0; virtual CHIP_ERROR SetForecast(DataModel::Nullable) = 0; From 956c3118f0a32b21d2089aa5e6c4c3c449c18e4a Mon Sep 17 00:00:00 2001 From: pcoleman Date: Fri, 7 Jun 2024 08:58:49 +0100 Subject: [PATCH 3/6] Address comments from Boris Zbarsky --- .../device-energy-management-server.cpp | 36 +++++++++++++++---- .../device-energy-management-server.h | 2 +- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp index 8e609813012024..085de856968dbc 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp @@ -681,7 +681,7 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: return; } - // Check to see if trying to modify a slot which have already been run + // Check to see if trying to modify a slot which has already been run if (!forecast.Value().activeSlotNumber.IsNull() && slotAdjustment.slotIndex < forecast.Value().activeSlotNumber.Value()) { ChipLogError(Zcl, "DEM: Modifying already run slot index %d", slotAdjustment.slotIndex); @@ -714,6 +714,12 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: } } + if (iterator.GetStatus() != CHIP_NO_ERROR) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidCommand); + return; + } + status = mDelegate.ModifyForecastRequest(forecastID, slotAdjustments, adjustmentCause); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) @@ -747,10 +753,10 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, } uint32_t currentUtcTime = 0; - status = GetCurrentUtcTime(currentUtcTime); + status = GetCurrentTimeEpochS(currentUtcTime); if (status != Status::Success) { - ChipLogError(Zcl, "DEM: Forecast is Null"); + ChipLogError(Zcl, "DEM: Failed to get UTC time"); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); return; } @@ -781,7 +787,11 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, if (constraint.nominalPower.Value() < mDelegate.GetAbsMinPower() || constraint.nominalPower.Value() > mDelegate.GetAbsMaxPower()) { - ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast nominalPower out of range [absMinPower, absMaxPower]"); + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast nominalPower " ChipLogFormatX64 " out of range [" ChipLogFormatX64 ", " ChipLogFormatX64 "]", + ChipLogValueX64(constraint.nominalPower.Value()), + ChipLogValueX64(mDelegate.GetAbsMinPower()), + ChipLogValueX64(mDelegate.GetAbsMaxPower())); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); return; } @@ -811,6 +821,12 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, } } } + + if (iterator.GetStatus() != CHIP_NO_ERROR) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidCommand); + return; + } } // Check for overlappping elements @@ -819,7 +835,7 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, if (iterator.Next()) { // Get the first constraint - const Structs::ConstraintsStruct::DecodableType & prevConstraint = iterator.GetValue(); + Structs::ConstraintsStruct::DecodableType prevConstraint = iterator.GetValue(); // Start comparing next vs prev constraints while (iterator.Next()) @@ -832,8 +848,16 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); return; } + + prevConstraint = iterator.GetValue(); } } + + if (iterator.GetStatus() != CHIP_NO_ERROR) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidCommand); + return; + } } status = mDelegate.RequestConstraintBasedForecast(constraints, adjustmentCause); @@ -868,7 +892,7 @@ void Instance::HandleCancelRequest(HandlerContext & ctx, const Commands::CancelR ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); } -Status Instance::GetCurrentUtcTime(uint32_t & currentUtcTime) const +Status Instance::GetCurrentTimeEpochS(uint32_t & currentUtcTime) const { currentUtcTime = 0; System::Clock::Milliseconds64 cTMs; diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.h b/src/app/clusters/device-energy-management-server/device-energy-management-server.h index cad3abc3db5a92..c7fd4734ae63a9 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.h +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.h @@ -203,7 +203,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface bool HasFeature(Feature aFeature) const; private: - Protocols::InteractionModel::Status GetCurrentUtcTime(uint32_t & currentUtcTime) const; + Protocols::InteractionModel::Status GetCurrentTimeEpochS(uint32_t & currentUtcTime) const; private: Delegate & mDelegate; From 40b185fa910068734e44417855ca99a233a8a59a Mon Sep 17 00:00:00 2001 From: pcoleman Date: Mon, 10 Jun 2024 08:14:40 +0100 Subject: [PATCH 4/6] Address some further useful comments from Boris Zbarsky --- .../device-energy-management-server.cpp | 8 ++++---- .../device-energy-management-server.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp index 085de856968dbc..b8e4807fdb8c4f 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp @@ -753,7 +753,7 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, } uint32_t currentUtcTime = 0; - status = GetCurrentTimeEpochS(currentUtcTime); + status = GetMatterEpochTimeFromUnixTime(currentUtcTime); if (status != Status::Success) { ChipLogError(Zcl, "DEM: Failed to get UTC time"); @@ -815,7 +815,7 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, if (constraint.loadControl.Value() < -100 || constraint.loadControl.Value() > 100) { - ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast bad loadControl %d", constraint.loadControl.HasValue()); + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast bad loadControl %d", constraint.loadControl.Value()); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); return; } @@ -849,7 +849,7 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, return; } - prevConstraint = iterator.GetValue(); + prevConstraint = constraint; } } @@ -892,7 +892,7 @@ void Instance::HandleCancelRequest(HandlerContext & ctx, const Commands::CancelR ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); } -Status Instance::GetCurrentTimeEpochS(uint32_t & currentUtcTime) const +Status Instance::GetMatterEpochTimeFromUnixTime(uint32_t & currentUtcTime) const { currentUtcTime = 0; System::Clock::Milliseconds64 cTMs; diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.h b/src/app/clusters/device-energy-management-server/device-energy-management-server.h index c7fd4734ae63a9..b0d27b0b99edd7 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.h +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.h @@ -203,7 +203,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface bool HasFeature(Feature aFeature) const; private: - Protocols::InteractionModel::Status GetCurrentTimeEpochS(uint32_t & currentUtcTime) const; + Protocols::InteractionModel::Status GetMatterEpochTimeFromUnixTime(uint32_t & currentUtcTime) const; private: Delegate & mDelegate; From b78eb4fc0e0b55403ecbd2778aa3d7200f272b41 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 10 Jun 2024 07:15:36 +0000 Subject: [PATCH 5/6] Restyled by clang-format --- .../device-energy-management-server.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp index b8e4807fdb8c4f..035a3daef71b88 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp @@ -787,9 +787,10 @@ void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, if (constraint.nominalPower.Value() < mDelegate.GetAbsMinPower() || constraint.nominalPower.Value() > mDelegate.GetAbsMaxPower()) { - ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast nominalPower " ChipLogFormatX64 " out of range [" ChipLogFormatX64 ", " ChipLogFormatX64 "]", - ChipLogValueX64(constraint.nominalPower.Value()), - ChipLogValueX64(mDelegate.GetAbsMinPower()), + ChipLogError(Zcl, + "DEM: RequestConstraintBasedForecast nominalPower " ChipLogFormatX64 + " out of range [" ChipLogFormatX64 ", " ChipLogFormatX64 "]", + ChipLogValueX64(constraint.nominalPower.Value()), ChipLogValueX64(mDelegate.GetAbsMinPower()), ChipLogValueX64(mDelegate.GetAbsMaxPower())); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); From 0f6d3ff552d850b9e72f289baea68a96786c3503 Mon Sep 17 00:00:00 2001 From: pcoleman Date: Thu, 13 Jun 2024 13:16:33 +0100 Subject: [PATCH 6/6] Merge from master and regenerate zap files --- .../outputs/all-clusters-app/app-templates/endpoint_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h index 61932b9136145e..8289394bce6d89 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h @@ -1202,7 +1202,7 @@ { ZAP_EMPTY_DEFAULT(), 0x00000002, 1, ZAP_TYPE(ENUM8), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ESAState */ \ { ZAP_EMPTY_DEFAULT(), 0x00000003, 8, ZAP_TYPE(POWER_MW), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* AbsMinPower */ \ { ZAP_EMPTY_DEFAULT(), 0x00000004, 8, ZAP_TYPE(POWER_MW), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* AbsMaxPower */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000005, 0, ZAP_TYPE(ARRAY), \ + { ZAP_EMPTY_DEFAULT(), 0x00000005, 0, ZAP_TYPE(STRUCT), \ ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE) }, /* PowerAdjustmentCapability */ \ { ZAP_EMPTY_DEFAULT(), 0x00000006, 0, ZAP_TYPE(STRUCT), \ ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE) }, /* Forecast */ \