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 cb54b4fd7a48d9..45be7ed614d227 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 @@ -3717,6 +3717,187 @@ provisional cluster ElectricalEnergyMeasurement = 145 { readonly attribute int16u clusterRevision = 65533; } +/** Electric Vehicle Supply Equipment (EVSE) is equipment used to charge an Electric Vehicle (EV) or Plug-In Hybrid Electric Vehicle. This cluster provides an interface to the functionality of Electric Vehicle Supply Equipment (EVSE) management. */ +provisional cluster EnergyEvse = 153 { + revision 1; // NOTE: Default/not specifically set + + enum EnergyTransferStoppedReasonEnum : enum8 { + kEVStopped = 0; + kEVSEStopped = 1; + kOther = 2; + } + + enum FaultStateEnum : enum8 { + kNoError = 0; + kMeterFailure = 1; + kOverVoltage = 2; + kUnderVoltage = 3; + kOverCurrent = 4; + kContactWetFailure = 5; + kContactDryFailure = 6; + kGroundFault = 7; + kPowerLoss = 8; + kPowerQuality = 9; + kPilotShortCircuit = 10; + kEmergencyStop = 11; + kEVDisconnected = 12; + kWrongPowerSupply = 13; + kLiveNeutralSwap = 14; + kOverTemperature = 15; + kOther = 255; + } + + enum StateEnum : enum8 { + kNotPluggedIn = 0; + kPluggedInNoDemand = 1; + kPluggedInDemand = 2; + kPluggedInCharging = 3; + kPluggedInDischarging = 4; + kSessionEnding = 5; + kFault = 6; + } + + enum SupplyStateEnum : enum8 { + kDisabled = 0; + kChargingEnabled = 1; + kDischargingEnabled = 2; + kDisabledError = 3; + kDisabledDiagnostics = 4; + } + + bitmap Feature : bitmap32 { + kChargingPreferences = 0x1; + kSoCReporting = 0x2; + kPlugAndCharge = 0x4; + kRFID = 0x8; + kV2X = 0x10; + } + + bitmap TargetDayOfWeekBitmap : bitmap8 { + kSunday = 0x1; + kMonday = 0x2; + kTuesday = 0x4; + kWednesday = 0x8; + kThursday = 0x10; + kFriday = 0x20; + kSaturday = 0x40; + } + + struct ChargingTargetStruct { + int16u targetTimeMinutesPastMidnight = 0; + optional percent targetSoC = 1; + optional energy_mwh addedEnergy = 2; + } + + info event EVConnected = 0 { + int32u sessionID = 0; + } + + info event EVNotDetected = 1 { + int32u sessionID = 0; + StateEnum state = 1; + elapsed_s sessionDuration = 2; + energy_mwh sessionEnergyCharged = 3; + optional energy_mwh sessionEnergyDischarged = 4; + } + + info event EnergyTransferStarted = 2 { + int32u sessionID = 0; + StateEnum state = 1; + amperage_ma maximumCurrent = 2; + } + + info event EnergyTransferStopped = 3 { + int32u sessionID = 0; + StateEnum state = 1; + EnergyTransferStoppedReasonEnum reason = 2; + energy_mwh energyTransferred = 4; + } + + critical event Fault = 4 { + nullable int32u sessionID = 0; + StateEnum state = 1; + FaultStateEnum faultStatePreviousState = 2; + FaultStateEnum faultStateCurrentState = 4; + } + + info event RFID = 5 { + octet_string uid = 0; + } + + readonly attribute nullable StateEnum state = 0; + readonly attribute SupplyStateEnum supplyState = 1; + readonly attribute FaultStateEnum faultState = 2; + readonly attribute nullable epoch_s chargingEnabledUntil = 3; + readonly attribute optional nullable epoch_s dischargingEnabledUntil = 4; + readonly attribute amperage_ma circuitCapacity = 5; + readonly attribute amperage_ma minimumChargeCurrent = 6; + readonly attribute amperage_ma maximumChargeCurrent = 7; + readonly attribute optional amperage_ma maximumDischargeCurrent = 8; + attribute access(write: manage) optional amperage_ma userMaximumChargeCurrent = 9; + attribute access(write: manage) optional elapsed_s randomizationDelayWindow = 10; + readonly attribute optional int8u numberOfWeeklyTargets = 33; + readonly attribute optional int8u numberOfDailyTargets = 34; + readonly attribute optional nullable epoch_s nextChargeStartTime = 35; + readonly attribute optional nullable epoch_s nextChargeTargetTime = 36; + readonly attribute optional nullable energy_mwh nextChargeRequiredEnergy = 37; + readonly attribute optional nullable percent nextChargeTargetSoC = 38; + attribute access(write: manage) optional nullable int16u approximateEVEfficiency = 39; + readonly attribute optional nullable percent stateOfCharge = 48; + readonly attribute optional nullable energy_mwh batteryCapacity = 49; + readonly attribute optional nullable char_string<32> vehicleID = 50; + readonly attribute nullable int32u sessionID = 64; + readonly attribute nullable elapsed_s sessionDuration = 65; + readonly attribute nullable energy_mwh sessionEnergyCharged = 66; + readonly attribute optional nullable energy_mwh sessionEnergyDischarged = 67; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + response struct GetTargetsResponse = 0 { + TargetDayOfWeekBitmap dayOfWeekforSequence = 0; + ChargingTargetStruct chargingTargets[] = 1; + } + + request struct EnableChargingRequest { + nullable epoch_s chargingEnabledUntil = 0; + amperage_ma minimumChargeCurrent = 1; + amperage_ma maximumChargeCurrent = 2; + } + + request struct EnableDischargingRequest { + nullable epoch_s dischargingEnabledUntil = 0; + amperage_ma maximumDischargeCurrent = 1; + } + + request struct SetTargetsRequest { + TargetDayOfWeekBitmap dayOfWeekforSequence = 0; + ChargingTargetStruct chargingTargets[] = 1; + } + + request struct GetTargetsRequest { + TargetDayOfWeekBitmap daysToReturn = 0; + } + + /** Allows a client to disable the EVSE from charging and discharging. */ + timed command Disable(): DefaultSuccess = 1; + /** Allows a client to enable the EVSE to charge an EV. */ + timed command EnableCharging(EnableChargingRequest): DefaultSuccess = 2; + /** Allows a client to enable the EVSE to discharge an EV. */ + timed command EnableDischarging(EnableDischargingRequest): DefaultSuccess = 3; + /** Allows a client to put the EVSE into a self-diagnostics mode. */ + timed command StartDiagnostics(): DefaultSuccess = 4; + /** Allows a client to set the user specified charging targets. */ + timed command SetTargets(SetTargetsRequest): DefaultSuccess = 5; + /** Allows a client to retrieve the user specified charging targets. */ + timed command GetTargets(GetTargetsRequest): GetTargetsResponse = 6; + /** Allows a client to clear all stored charging targets. */ + timed command ClearTargets(): DefaultSuccess = 7; +} + /** Provides an interface for controlling and adjusting automatic window coverings. */ cluster WindowCovering = 258 { revision 5; @@ -7141,6 +7322,40 @@ endpoint 1 { ram attribute clusterRevision default = 1; } + server cluster EnergyEvse { + callback attribute state default = 0; + callback attribute supplyState default = 0; + callback attribute faultState default = 0; + callback attribute chargingEnabledUntil default = 0; + callback attribute dischargingEnabledUntil default = 0; + callback attribute circuitCapacity default = 0; + callback attribute minimumChargeCurrent default = 6000; + callback attribute maximumChargeCurrent default = 0; + callback attribute maximumDischargeCurrent default = 0; + callback attribute userMaximumChargeCurrent default = 0; + callback attribute randomizationDelayWindow default = 600; + callback attribute numberOfWeeklyTargets default = 0; + callback attribute numberOfDailyTargets default = 1; + callback attribute nextChargeStartTime; + callback attribute nextChargeTargetTime; + callback attribute nextChargeRequiredEnergy; + callback attribute nextChargeTargetSoC; + callback attribute approximateEVEfficiency default = 0xFFFF; + callback attribute stateOfCharge; + callback attribute batteryCapacity; + callback attribute vehicleID; + callback attribute sessionID; + callback attribute sessionDuration; + callback attribute sessionEnergyCharged; + callback attribute sessionEnergyDischarged; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 2; + } + server cluster WindowCovering { ram attribute type default = 0x08; ram attribute physicalClosedLimitLift default = 0xFFFF; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 2a331d5674f0e4..69c6f8ec0cb8de 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -17,12 +17,6 @@ } ], "package": [ - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" - }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json", @@ -30,6 +24,12 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data with some extensions" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" } ], "endpointTypes": [ @@ -7099,6 +7099,7 @@ "define": "ON_OFF_SWITCH_CONFIGURATION_CLUSTER", "side": "server", "enabled": 1, + "apiMaturity": "deprecated", "attributes": [ { "name": "switch type", @@ -7505,6 +7506,7 @@ "define": "BINARY_INPUT_BASIC_CLUSTER", "side": "server", "enabled": 1, + "apiMaturity": "deprecated", "attributes": [ { "name": "out of service", @@ -11533,25 +11535,9 @@ "enabled": 1, "apiMaturity": "provisional", "attributes": [ - { - "name": "Measured", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "false", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "Accuracy", - "code": 1, + "code": 0, "mfgCode": null, "side": "server", "type": "MeasurementAccuracyStruct", @@ -11567,7 +11553,7 @@ }, { "name": "CumulativeEnergyImported", - "code": 2, + "code": 1, "mfgCode": null, "side": "server", "type": "EnergyMeasurementStruct", @@ -11583,7 +11569,7 @@ }, { "name": "CumulativeEnergyExported", - "code": 3, + "code": 2, "mfgCode": null, "side": "server", "type": "EnergyMeasurementStruct", @@ -11599,7 +11585,7 @@ }, { "name": "PeriodicEnergyImported", - "code": 4, + "code": 3, "mfgCode": null, "side": "server", "type": "EnergyMeasurementStruct", @@ -11615,7 +11601,7 @@ }, { "name": "PeriodicEnergyExported", - "code": 5, + "code": 4, "mfgCode": null, "side": "server", "type": "EnergyMeasurementStruct", @@ -11744,303 +11730,810 @@ ] }, { - "name": "Window Covering", - "code": 258, + "name": "Energy EVSE", + "code": 153, "mfgCode": null, - "define": "WINDOW_COVERING_CLUSTER", + "define": "ENERGY_EVSE_CLUSTER", "side": "server", "enabled": 1, - "commands": [ - { - "name": "UpOrOpen", - "code": 0, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "DownOrClose", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "StopMotion", - "code": 2, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "GoToLiftValue", - "code": 4, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "GoToLiftPercentage", - "code": 5, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "GoToTiltValue", - "code": 7, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "GoToTiltPercentage", - "code": 8, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - } - ], + "apiMaturity": "provisional", "attributes": [ { - "name": "Type", + "name": "State", "code": 0, "mfgCode": null, "side": "server", - "type": "Type", + "type": "StateEnum", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "PhysicalClosedLimitLift", + "name": "SupplyState", "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "SupplyStateEnum", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0xFFFF", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65545, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "PhysicalClosedLimitTilt", + "name": "FaultState", "code": 2, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "FaultStateEnum", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0xFFFF", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65545, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CurrentPositionLift", + "name": "ChargingEnabledUntil", "code": 3, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "epoch_s", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x7FFF", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CurrentPositionTilt", + "name": "DischargingEnabledUntil", "code": 4, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "epoch_s", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x7FFF", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "NumberOfActuationsLift", + "name": "CircuitCapacity", "code": 5, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "amperage_ma", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65545, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "NumberOfActuationsTilt", + "name": "MinimumChargeCurrent", "code": 6, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "amperage_ma", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "6000", "reportable": 1, - "minInterval": 0, - "maxInterval": 65545, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ConfigStatus", + "name": "MaximumChargeCurrent", "code": 7, "mfgCode": null, "side": "server", - "type": "ConfigStatus", + "type": "amperage_ma", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x03", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CurrentPositionLiftPercentage", + "name": "MaximumDischargeCurrent", "code": 8, "mfgCode": null, "side": "server", - "type": "percent", + "type": "amperage_ma", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "50", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 100, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CurrentPositionTiltPercentage", + "name": "UserMaximumChargeCurrent", "code": 9, "mfgCode": null, "side": "server", - "type": "percent", + "type": "amperage_ma", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "50", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 100, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "OperationalStatus", + "name": "RandomizationDelayWindow", "code": 10, "mfgCode": null, "side": "server", - "type": "OperationalStatus", + "type": "elapsed_s", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "600", "reportable": 1, - "minInterval": 0, - "maxInterval": 127, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "TargetPositionLiftPercent100ths", - "code": 11, + "name": "NumberOfWeeklyTargets", + "code": 33, "mfgCode": null, "side": "server", - "type": "percent100ths", + "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "5000", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 10000, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "TargetPositionTiltPercent100ths", - "code": 12, + "name": "NumberOfDailyTargets", + "code": 34, "mfgCode": null, "side": "server", - "type": "percent100ths", + "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "5000", + "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 10000, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "EndProductType", - "code": 13, + "name": "NextChargeStartTime", + "code": 35, "mfgCode": null, "side": "server", - "type": "EndProductType", + "type": "epoch_s", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CurrentPositionLiftPercent100ths", - "code": 14, + "name": "NextChargeTargetTime", + "code": 36, "mfgCode": null, "side": "server", - "type": "percent100ths", + "type": "epoch_s", "included": 1, - "storageOption": "NVM", + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NextChargeRequiredEnergy", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "energy_mwh", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NextChargeTargetSoC", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "percent", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ApproximateEVEfficiency", + "code": 39, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFFFF", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "StateOfCharge", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "percent", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BatteryCapacity", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "energy_mwh", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "VehicleID", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SessionID", + "code": 64, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SessionDuration", + "code": 65, + "mfgCode": null, + "side": "server", + "type": "elapsed_s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SessionEnergyCharged", + "code": 66, + "mfgCode": null, + "side": "server", + "type": "energy_mwh", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SessionEnergyDischarged", + "code": 67, + "mfgCode": null, + "side": "server", + "type": "energy_mwh", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Window Covering", + "code": 258, + "mfgCode": null, + "define": "WINDOW_COVERING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "UpOrOpen", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "DownOrClose", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "StopMotion", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "GoToLiftValue", + "code": 4, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "GoToLiftPercentage", + "code": 5, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "GoToTiltValue", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "GoToTiltPercentage", + "code": 8, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], + "attributes": [ + { + "name": "Type", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "Type", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x08", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PhysicalClosedLimitLift", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFFFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65545, + "reportableChange": 0 + }, + { + "name": "PhysicalClosedLimitTilt", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFFFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65545, + "reportableChange": 0 + }, + { + "name": "CurrentPositionLift", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x7FFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentPositionTilt", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x7FFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NumberOfActuationsLift", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65545, + "reportableChange": 0 + }, + { + "name": "NumberOfActuationsTilt", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65545, + "reportableChange": 0 + }, + { + "name": "ConfigStatus", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "ConfigStatus", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x03", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentPositionLiftPercentage", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "percent", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "50", + "reportable": 1, + "minInterval": 0, + "maxInterval": 100, + "reportableChange": 0 + }, + { + "name": "CurrentPositionTiltPercentage", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "percent", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "50", + "reportable": 1, + "minInterval": 0, + "maxInterval": 100, + "reportableChange": 0 + }, + { + "name": "OperationalStatus", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "OperationalStatus", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 127, + "reportableChange": 0 + }, + { + "name": "TargetPositionLiftPercent100ths", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "percent100ths", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 10000, + "reportableChange": 0 + }, + { + "name": "TargetPositionTiltPercent100ths", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "percent100ths", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 10000, + "reportableChange": 0 + }, + { + "name": "EndProductType", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "EndProductType", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentPositionLiftPercent100ths", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "percent100ths", + "included": 1, + "storageOption": "NVM", "singleton": 0, "bounded": 0, "defaultValue": "5000", @@ -12250,6 +12743,7 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "server", "enabled": 1, + "apiMaturity": "deprecated", "commands": [ { "name": "BarrierControlGoToPercent", @@ -12880,7 +13374,7 @@ "code": 17, "mfgCode": null, "side": "server", - "type": "temperature", + "type": "int16s", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -12896,7 +13390,7 @@ "code": 18, "mfgCode": null, "side": "server", - "type": "temperature", + "type": "int16s", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -12912,7 +13406,7 @@ "code": 21, "mfgCode": null, "side": "server", - "type": "temperature", + "type": "int16s", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -12928,7 +13422,7 @@ "code": 22, "mfgCode": null, "side": "server", - "type": "temperature", + "type": "int16s", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -12944,7 +13438,7 @@ "code": 23, "mfgCode": null, "side": "server", - "type": "temperature", + "type": "int16s", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -12960,7 +13454,7 @@ "code": 24, "mfgCode": null, "side": "server", - "type": "temperature", + "type": "int16s", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -13061,7 +13555,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -18192,6 +18686,7 @@ "define": "ELECTRICAL_MEASUREMENT_CLUSTER", "side": "server", "enabled": 1, + "apiMaturity": "deprecated", "attributes": [ { "name": "measurement type", @@ -21961,4 +22456,4 @@ } ], "log": [] -} +} \ No newline at end of file diff --git a/examples/all-clusters-app/all-clusters-common/include/EnergyEvseDelegateImpl.h b/examples/all-clusters-app/all-clusters-common/include/EnergyEvseDelegateImpl.h new file mode 100644 index 00000000000000..0a967e2472be8b --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/include/EnergyEvseDelegateImpl.h @@ -0,0 +1,196 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "app/clusters/energy-evse-server/energy-evse-server.h" + +#include +#include +#include + +using chip::Protocols::InteractionModel::Status; +namespace chip { +namespace app { +namespace Clusters { +namespace EnergyEvse { + +/** + * The application delegate. + */ + +class EnergyEvseDelegate : public EnergyEvse::Delegate +{ +public: + ~EnergyEvseDelegate(); + + /** + * @brief Called when EVSE cluster receives Disable command + */ + Status Disable() override; + + /** + * @brief Called when EVSE cluster receives EnableCharging command + * + * @param chargingEnabledUntil + * @param minimumChargeCurrent (in mA) + * @param maximumChargeCurrent (in mA) + */ + Status EnableCharging(const DataModel::Nullable & chargingEnabledUntil, const int64_t & minimumChargeCurrent, + const int64_t & maximumChargeCurrent) override; + + /** + * @brief Called when EVSE cluster receives EnableDischarging command + * + * @param dischargingEnabledUntil + * @param maximumChargeCurrent (in mA) + */ + Status EnableDischarging(const DataModel::Nullable & dischargingEnabledUntil, + const int64_t & maximumDischargeCurrent) override; + + /** + * @brief Called when EVSE cluster receives StartDiagnostics command + */ + Status StartDiagnostics() override; + + // ----------------------------------------------------------------- + // Internal API to allow an EVSE to change its internal state etc + // TODO Status HwRegisterEvseHardwareCallback(Callback); + Status HwSetMaxHardwareCurrentLimit(int64_t currentmA); + Status HwSetCircuitCapacity(int64_t currentmA); + Status HwSetCableAssemblyLimit(int64_t currentmA); + Status HwSetState(StateEnum state); + Status HwSetFault(FaultStateEnum fault); + Status HwSetRFID(ByteSpan uid); + Status HwSetVehicleID(const CharSpan & vehID); + + // ------------------------------------------------------------------ + // Get attribute methods + StateEnum GetState() override; + CHIP_ERROR SetState(StateEnum); + + SupplyStateEnum GetSupplyState() override; + CHIP_ERROR SetSupplyState(SupplyStateEnum); + + FaultStateEnum GetFaultState() override; + CHIP_ERROR SetFaultState(FaultStateEnum); + + DataModel::Nullable GetChargingEnabledUntil() override; + CHIP_ERROR SetChargingEnabledUntil(uint32_t); + + DataModel::Nullable GetDischargingEnabledUntil() override; + CHIP_ERROR SetDischargingEnabledUntil(uint32_t); + + int64_t GetCircuitCapacity() override; + CHIP_ERROR SetCircuitCapacity(int64_t); + + int64_t GetMinimumChargeCurrent() override; + CHIP_ERROR SetMinimumChargeCurrent(int64_t); + + int64_t GetMaximumChargeCurrent() override; + CHIP_ERROR SetMaximumChargeCurrent(int64_t); + + int64_t GetMaximumDischargeCurrent() override; + CHIP_ERROR SetMaximumDischargeCurrent(int64_t); + + int64_t GetUserMaximumChargeCurrent() override; + CHIP_ERROR SetUserMaximumChargeCurrent(int64_t) override; + + uint32_t GetRandomizationDelayWindow() override; + CHIP_ERROR SetRandomizationDelayWindow(uint32_t) override; + + /* PREF attributes */ + uint8_t GetNumberOfWeeklyTargets() override; + uint8_t GetNumberOfDailyTargets() override; + DataModel::Nullable GetNextChargeStartTime() override; + DataModel::Nullable GetNextChargeTargetTime() override; + DataModel::Nullable GetNextChargeRequiredEnergy() override; + DataModel::Nullable GetNextChargeTargetSoC() override; + + DataModel::Nullable GetApproximateEVEfficiency() override; + CHIP_ERROR SetApproximateEVEfficiency(uint16_t) override; + + /* SOC attributes */ + DataModel::Nullable GetStateOfCharge() override; + DataModel::Nullable GetBatteryCapacity() override; + /* PNC attributes*/ + DataModel::Nullable GetVehicleID() override; + /* Session SESS attributes */ + DataModel::Nullable GetSessionID() override; + DataModel::Nullable GetSessionDuration() override; + DataModel::Nullable GetSessionEnergyCharged() override; + DataModel::Nullable GetSessionEnergyDischarged() override; + +private: + /* Constants */ + static constexpr int DEFAULT_MIN_CHARGE_CURRENT = 6000; /* 6A */ + static constexpr int DEFAULT_USER_MAXIMUM_CHARGE_CURRENT = kMaximumChargeCurrent; /* 80A */ + static constexpr int DEFAULT_RANDOMIZATION_DELAY_WINDOW = 600; /* 600s */ + static constexpr int kMaxVehicleIDBufSize = 32; + + /* private variables for controlling the hardware - these are not attributes */ + int64_t mMaxHardwareCurrentLimit = 0; /* Hardware current limit in mA */ + int64_t mCableAssemblyCurrentLimit = 0; /* Cable limit detected when cable is plugged in, in mA */ + int64_t mMaximumChargingCurrentLimitFromCommand = 0; /* Value of current maximum limit when charging enabled */ + int64_t mActualChargingCurrentLimit = 0; + StateEnum mHwState = StateEnum::kNotPluggedIn; /* Hardware state */ + + /** + * @brief Helper function to work out the charge limit based on conditions and settings + */ + Status ComputeMaxChargeCurrentLimit(); + + /* Attributes */ + StateEnum mState = StateEnum::kNotPluggedIn; + SupplyStateEnum mSupplyState = SupplyStateEnum::kDisabled; + FaultStateEnum mFaultState = FaultStateEnum::kNoError; + DataModel::Nullable mChargingEnabledUntil; // TODO Default to 0 to indicate disabled + DataModel::Nullable mDischargingEnabledUntil; // TODO Default to 0 to indicate disabled + int64_t mCircuitCapacity = 0; + int64_t mMinimumChargeCurrent = DEFAULT_MIN_CHARGE_CURRENT; + int64_t mMaximumChargeCurrent = 0; + int64_t mMaximumDischargeCurrent = 0; + int64_t mUserMaximumChargeCurrent = DEFAULT_USER_MAXIMUM_CHARGE_CURRENT; // TODO update spec + uint32_t mRandomizationDelayWindow = DEFAULT_RANDOMIZATION_DELAY_WINDOW; + /* PREF attributes */ + uint8_t mNumberOfWeeklyTargets = 0; + uint8_t mNumberOfDailyTargets = 1; + DataModel::Nullable mNextChargeStartTime; + DataModel::Nullable mNextChargeTargetTime; + DataModel::Nullable mNextChargeRequiredEnergy; + DataModel::Nullable mNextChargeTargetSoC; + DataModel::Nullable mApproximateEVEfficiency; + + /* SOC attributes */ + DataModel::Nullable mStateOfCharge; + DataModel::Nullable mBatteryCapacity; + + /* PNC attributes*/ + DataModel::Nullable mVehicleID; + + /* Session SESS attributes */ + DataModel::Nullable mSessionID; + DataModel::Nullable mSessionDuration; + DataModel::Nullable mSessionEnergyCharged; + DataModel::Nullable mSessionEnergyDischarged; +}; + +} // namespace EnergyEvse +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/examples/all-clusters-app/all-clusters-common/include/EnergyEvseManager.h b/examples/all-clusters-app/all-clusters-common/include/EnergyEvseManager.h new file mode 100644 index 00000000000000..9875c397990ef2 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/include/EnergyEvseManager.h @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +namespace chip { +namespace app { +namespace Clusters { + +using namespace chip::app::Clusters::EnergyEvse; +class EnergyEvseManager : public Instance +{ +public: + EnergyEvseManager(EndpointId aEndpointId, EnergyEvseDelegate & aDelegate, Feature aFeature, OptionalAttributes aOptionalAttrs, + OptionalCommands aOptionalCmds) : + EnergyEvse::Instance(aEndpointId, aDelegate, aFeature, aOptionalAttrs, aOptionalCmds) + { + mDelegate = &aDelegate; + } + + // Delete copy constructor and assignment operator. + EnergyEvseManager(const EnergyEvseManager &) = delete; + EnergyEvseManager(const EnergyEvseManager &&) = delete; + EnergyEvseManager & operator=(const EnergyEvseManager &) = delete; + + CHIP_ERROR Init(); + void Shutdown(); + + EnergyEvseDelegate * GetDelegate() { return mDelegate; }; + +private: + EnergyEvseDelegate * mDelegate; +}; + +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp b/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp new file mode 100644 index 00000000000000..64d8b98bafc644 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp @@ -0,0 +1,793 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::DataModel; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::EnergyEvse; +using namespace chip::app::Clusters::EnergyEvse::Attributes; + +using chip::app::LogEvent; +using chip::Protocols::InteractionModel::Status; + +EnergyEvseDelegate::~EnergyEvseDelegate() +{ + // TODO Fix this as part of issue #30993 refactoring + if (!mVehicleID.IsNull()) + { + ChipLogDetail(AppServer, "Freeing VehicleID"); + delete[] mVehicleID.Value().data(); + } +} + +/** + * @brief Called when EVSE cluster receives Disable command + */ +Status EnergyEvseDelegate::Disable() +{ + ChipLogProgress(AppServer, "EnergyEvseDelegate::Disable()"); + + /* Update State */ + switch (mHwState) + { + case StateEnum::kNotPluggedIn: + SetState(StateEnum::kNotPluggedIn); + break; + + case StateEnum::kPluggedInNoDemand: + SetState(StateEnum::kPluggedInNoDemand); + break; + + case StateEnum::kPluggedInDemand: + SetState(StateEnum::kPluggedInDemand); + break; + + default: + ChipLogError(AppServer, "Unexpected EVSE hardware state"); + SetState(StateEnum::kFault); + break; + } + + /* update SupplyState */ + SetSupplyState(SupplyStateEnum::kDisabled); + + /* update ChargingEnabledUntil & DischargingEnabledUntil to show 0 */ + SetChargingEnabledUntil(0); + SetDischargingEnabledUntil(0); + + /* update MinimumChargeCurrent & MaximumChargeCurrent to 0 */ + SetMinimumChargeCurrent(0); + SetMaximumChargeCurrent(0); + + /* update MaximumDischargeCurrent to 0 */ + SetMaximumDischargeCurrent(0); + + // TODO: Generate events + + return Status::Success; +} + +/** + * @brief Called when EVSE cluster receives EnableCharging command + * + * @param chargingEnabledUntil (can be null to indefinite charging) + * @param minimumChargeCurrent (in mA) + * @param maximumChargeCurrent (in mA) + */ +Status EnergyEvseDelegate::EnableCharging(const DataModel::Nullable & chargingEnabledUntil, + const int64_t & minimumChargeCurrent, const int64_t & maximumChargeCurrent) +{ + ChipLogProgress(AppServer, "EnergyEvseDelegate::EnableCharging()"); + + if (maximumChargeCurrent < kMinimumChargeCurrent || maximumChargeCurrent > kMaximumChargeCurrent) + { + ChipLogError(NotSpecified, "Maximum Current outside limits"); + return Status::ConstraintError; + } + + if (minimumChargeCurrent < kMinimumChargeCurrent || minimumChargeCurrent > kMaximumChargeCurrent) + { + ChipLogError(NotSpecified, "Maximum Current outside limits"); + return Status::ConstraintError; + } + + if (minimumChargeCurrent > maximumChargeCurrent) + { + ChipLogError(NotSpecified, "Minium Current > Maximum Current!"); + return Status::ConstraintError; + } + + if (chargingEnabledUntil.IsNull()) + { + /* Charging enabled indefinitely */ + ChipLogError(NotSpecified, "Charging enabled indefinitely"); + } + else + { + /* check chargingEnabledUntil is in the future */ + ChipLogError(NotSpecified, "Charging enabled until: %lu", static_cast(chargingEnabledUntil.Value())); + // TODO + // if (checkChargingEnabled) + } + + /* Check current state isn't already enabled */ + + /* If charging is already enabled, check that the parameters may have + changed, these may override an existing charging command */ + switch (mHwState) + { + case StateEnum::kNotPluggedIn: + // TODO handle errors here + SetState(StateEnum::kNotPluggedIn); + break; + + case StateEnum::kPluggedInNoDemand: + // TODO handle errors here + // TODO REFACTOR per Andrei's comment in PR30857 - can we collapse this switch statement? + SetState(StateEnum::kPluggedInNoDemand); + break; + + case StateEnum::kPluggedInDemand: + /* If the EVSE is asking for demand then enable charging */ + SetState(StateEnum::kPluggedInCharging); + break; + + default: + ChipLogError(AppServer, "Unexpected EVSE hardware state"); + SetState(StateEnum::kFault); + break; + } + + /* update SupplyState to say that charging is now enabled */ + SetSupplyState(SupplyStateEnum::kChargingEnabled); + + /* If it looks ok, store the min & max charging current */ + mMaximumChargingCurrentLimitFromCommand = maximumChargeCurrent; + SetMinimumChargeCurrent(minimumChargeCurrent); + // TODO persist these to KVS + + // TODO: Generate events + + return this->ComputeMaxChargeCurrentLimit(); +} + +/** + * @brief Called when EVSE cluster receives EnableDischarging command + * + * @param dischargingEnabledUntil (can be null to indefinite discharging) + * @param maximumChargeCurrent (in mA) + */ +Status EnergyEvseDelegate::EnableDischarging(const DataModel::Nullable & dischargingEnabledUntil, + const int64_t & maximumDischargeCurrent) +{ + ChipLogProgress(AppServer, "EnergyEvseDelegate::EnableDischarging() called."); + + /* update SupplyState */ + SetSupplyState(SupplyStateEnum::kDischargingEnabled); + + // TODO: Generate events + + return Status::Success; +} + +/** + * @brief Called when EVSE cluster receives StartDiagnostics command + */ +Status EnergyEvseDelegate::StartDiagnostics() +{ + /* For EVSE manufacturers to customize */ + ChipLogProgress(AppServer, "EnergyEvseDelegate::StartDiagnostics()"); + + /* update SupplyState */ + SetSupplyState(SupplyStateEnum::kDisabledDiagnostics); + + // TODO: Generate events + + return Status::Success; +} + +/* --------------------------------------------------------------------------- + * FUNCTIONS BELOW: + * - EVSE Hardware interface + * + * SetMaxHardwareCurrentLimit( currentmA ) + * SetCircuitCapacity( currentmA ) + * SetCableAssemblyLimit( currentmA ) + * SetState( EVSEStateEnum ) + * SetFault + * + */ + +/** + * @brief Called by EVSE Hardware to notify the delegate of the maximum + * current limit supported by the hardware. + * + * This is normally called at start-up. + * + * @param currentmA - Maximum current limit supported by the hardware + */ +Status EnergyEvseDelegate::HwSetMaxHardwareCurrentLimit(int64_t currentmA) +{ + if (currentmA < kMinimumChargeCurrent || currentmA > kMaximumChargeCurrent) + { + return Status::ConstraintError; + } + + /* there is no attribute to store this so store in private variable */ + mMaxHardwareCurrentLimit = currentmA; + + return this->ComputeMaxChargeCurrentLimit(); +} + +/** + * @brief Called by EVSE Hardware to notify the delegate of maximum electrician + * set current limit. + * + * This is normally called at start-up when reading from DIP-switch + * settings. + * + * @param currentmA - Maximum current limit specified by electrician + */ +Status EnergyEvseDelegate::HwSetCircuitCapacity(int64_t currentmA) +{ + if (currentmA < kMinimumChargeCurrent || currentmA > kMaximumChargeCurrent) + { + return Status::ConstraintError; + } + + mCircuitCapacity = currentmA; + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, CircuitCapacity::Id); + + return this->ComputeMaxChargeCurrentLimit(); +} + +/** + * @brief Called by EVSE Hardware to notify the delegate of the cable assembly + * current limit. + * + * This is normally called when the EV is plugged into the EVSE and the + * PP voltage is measured by the EVSE. A pull-up resistor in the cable + * causes a voltage drop. Different current limits can be indicated + * using different resistors, which results in different voltages + * measured by the EVSE. + * + * @param currentmA - Maximum current limit detected from Cable assembly + */ +Status EnergyEvseDelegate::HwSetCableAssemblyLimit(int64_t currentmA) +{ + if (currentmA < kMinimumChargeCurrent || currentmA > kMaximumChargeCurrent) + { + return Status::ConstraintError; + } + + /* there is no attribute to store this so store in private variable */ + mCableAssemblyCurrentLimit = currentmA; + + return this->ComputeMaxChargeCurrentLimit(); +} + +/** + * @brief Called by EVSE Hardware to indicate if EV is detected + * + * The only allowed states that the EVSE hardware can set are: + * kNotPluggedIn + * kPluggedInNoDemand + * kPluggedInDemand + * + * @param StateEnum - the state of the EV being plugged in and asking for demand etc + */ +Status EnergyEvseDelegate::HwSetState(StateEnum state) +{ + switch (state) + { + case StateEnum::kNotPluggedIn: + // TODO - work out logic here + mHwState = state; + break; + case StateEnum::kPluggedInNoDemand: + // TODO - work out logic here + mHwState = state; + break; + case StateEnum::kPluggedInDemand: + // TODO - work out logic here + mHwState = state; + break; + + default: + /* All other states should be managed by the Delegate */ + // TODO (assert?) + break; + } + + return Status::Success; +} + +/** + * @brief Called by EVSE Hardware to indicate a fault + * + * @param FaultStateEnum - the fault condition detected + */ +Status EnergyEvseDelegate::HwSetFault(FaultStateEnum fault) +{ + ChipLogProgress(AppServer, "EnergyEvseDelegate::Fault()"); + + if (fault == FaultStateEnum::kNoError) + { + /* Update State to previous state */ + // TODO: need to work out the logic here! + + /* Update SupplyState to previous state */ + } + else + { + /* Update State & SupplyState */ + SetState(StateEnum::kFault); + SetSupplyState(SupplyStateEnum::kDisabledError); + } + + /* Update FaultState */ + SetFaultState(fault); + + // TODO: Generate events + + return Status::Success; +} + +/** + * @brief Called by EVSE Hardware to Send a RFID event + * + * @param ByteSpan RFID tag value (max 10 octets) + */ +Status EnergyEvseDelegate::HwSetRFID(ByteSpan uid) +{ + Events::Rfid::Type event{ .uid = uid }; + EventNumber eventNumber; + CHIP_ERROR error = LogEvent(event, mEndpointId, eventNumber); + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "[Notify] Unable to send notify event: %s [endpointId=%d]", error.AsString(), mEndpointId); + return Status::Failure; + } + + return Status::Success; +} + +/** + * @brief Called by EVSE Hardware to share the VehicleID + * + * This routine will make a copy of the string so the callee doesn't + * have to hold onto it forever. + * + * @param CharSpan containing up to 32 chars. + */ +Status EnergyEvseDelegate::HwSetVehicleID(const CharSpan & newValue) +{ + // TODO this code to be refactored - See Issue #30993 + if (!mVehicleID.IsNull() && newValue.data_equal(mVehicleID.Value())) + { + return Status::Success; + } + + /* create a copy of the string so the callee doesn't have to keep it */ + char * destinationBuffer = new char[kMaxVehicleIDBufSize]; + + MutableCharSpan destinationString(destinationBuffer, kMaxVehicleIDBufSize); + CHIP_ERROR err = CopyCharSpanToMutableCharSpan(newValue, destinationString); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "HwSetVehicleID - could not copy vehicleID"); + delete[] destinationBuffer; + return Status::Failure; + } + + if (!mVehicleID.IsNull()) + { + delete[] mVehicleID.Value().data(); + } + + mVehicleID = MakeNullable(static_cast(destinationString)); + + ChipLogDetail(AppServer, "VehicleID updated %.*s", static_cast(mVehicleID.Value().size()), mVehicleID.Value().data()); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, VehicleID::Id); + + return Status::Success; +} + +/* --------------------------------------------------------------------------- + * Functions below are private helper functions internal to the delegate + */ + +/** + * @brief Called to compute the safe charging current limit + */ +Status EnergyEvseDelegate::ComputeMaxChargeCurrentLimit() +{ + int64_t oldValue; + /* mActualChargingCurrentLimit is the minimum of: + * - MaxHardwareCurrentLimit (of the hardware) + * - CircuitCapacity (set by the electrician - less than the hardware) + * - CableAssemblyLimit (detected when the cable is inserted) + * - MaximumChargeCurrent (from charging command) + * - UserMaximumChargeCurrent (could dynamically change) + */ + + oldValue = mActualChargingCurrentLimit; + mActualChargingCurrentLimit = mMaxHardwareCurrentLimit; + mActualChargingCurrentLimit = min(mActualChargingCurrentLimit, mCircuitCapacity); + mActualChargingCurrentLimit = min(mActualChargingCurrentLimit, mCableAssemblyCurrentLimit); + mActualChargingCurrentLimit = min(mActualChargingCurrentLimit, mMaximumChargingCurrentLimitFromCommand); + mActualChargingCurrentLimit = min(mActualChargingCurrentLimit, mUserMaximumChargeCurrent); + + /* Set the actual max charging current attribute */ + mMaximumChargeCurrent = mActualChargingCurrentLimit; + + if (oldValue != mMaximumChargeCurrent) + { + ChipLogDetail(AppServer, "MaximumChargeCurrent updated to %ld", static_cast(mMaximumChargeCurrent)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, MaximumChargeCurrent::Id); + + /* Call the EV Charger hardware current limit callback */ + // TODO + } + return Status::Success; +} + +/** + * Attribute methods + */ +/* State */ +StateEnum EnergyEvseDelegate::GetState() +{ + return mState; +} + +CHIP_ERROR EnergyEvseDelegate::SetState(StateEnum newValue) +{ + StateEnum oldValue = mState; + if (newValue >= StateEnum::kUnknownEnumValue) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mState = newValue; + if (oldValue != mState) + { + ChipLogDetail(AppServer, "State updated to %d", static_cast(mState)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, State::Id); + } + + return CHIP_NO_ERROR; +} + +/* SupplyState */ +SupplyStateEnum EnergyEvseDelegate::GetSupplyState() +{ + return mSupplyState; +} + +CHIP_ERROR EnergyEvseDelegate::SetSupplyState(SupplyStateEnum newValue) +{ + SupplyStateEnum oldValue = mSupplyState; + + if (newValue >= SupplyStateEnum::kUnknownEnumValue) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mSupplyState = newValue; + if (oldValue != mSupplyState) + { + ChipLogDetail(AppServer, "SupplyState updated to %d", static_cast(mSupplyState)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, SupplyState::Id); + } + return CHIP_NO_ERROR; +} + +/* FaultState */ +FaultStateEnum EnergyEvseDelegate::GetFaultState() +{ + return mFaultState; +} + +CHIP_ERROR EnergyEvseDelegate::SetFaultState(FaultStateEnum newValue) +{ + FaultStateEnum oldValue = mFaultState; + + if (newValue >= FaultStateEnum::kUnknownEnumValue) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mFaultState = newValue; + if (oldValue != mFaultState) + { + ChipLogDetail(AppServer, "FaultState updated to %d", static_cast(mFaultState)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, FaultState::Id); + } + return CHIP_NO_ERROR; +} + +/* ChargingEnabledUntil */ +DataModel::Nullable EnergyEvseDelegate::GetChargingEnabledUntil() +{ + return mChargingEnabledUntil; +} + +CHIP_ERROR EnergyEvseDelegate::SetChargingEnabledUntil(uint32_t newValue) +{ + DataModel::Nullable oldValue = mChargingEnabledUntil; + + mChargingEnabledUntil = MakeNullable(newValue); + if ((oldValue.IsNull()) || (oldValue.Value() != newValue)) + { + ChipLogDetail(AppServer, "ChargingEnabledUntil updated to %lu", + static_cast(mChargingEnabledUntil.Value())); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, ChargingEnabledUntil::Id); + } + return CHIP_NO_ERROR; +} + +/* DischargingEnabledUntil */ +DataModel::Nullable EnergyEvseDelegate::GetDischargingEnabledUntil() +{ + return mDischargingEnabledUntil; +} + +CHIP_ERROR EnergyEvseDelegate::SetDischargingEnabledUntil(uint32_t newValue) +{ + DataModel::Nullable oldValue = mDischargingEnabledUntil; + + mDischargingEnabledUntil = MakeNullable(newValue); + if ((oldValue.IsNull()) || (oldValue.Value() != newValue)) + { + ChipLogDetail(AppServer, "DischargingEnabledUntil updated to %lu", + static_cast(mDischargingEnabledUntil.Value())); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, DischargingEnabledUntil::Id); + } + return CHIP_NO_ERROR; +} + +/* CircuitCapacity */ +int64_t EnergyEvseDelegate::GetCircuitCapacity() +{ + return mCircuitCapacity; +} + +CHIP_ERROR EnergyEvseDelegate::SetCircuitCapacity(int64_t newValue) +{ + int64_t oldValue = mCircuitCapacity; + + if (newValue >= kMaximumChargeCurrent) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mCircuitCapacity = newValue; + if (oldValue != mCircuitCapacity) + { + ChipLogDetail(AppServer, "CircuitCapacity updated to %ld", static_cast(mCircuitCapacity)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, CircuitCapacity::Id); + } + return CHIP_NO_ERROR; +} + +/* MinimumChargeCurrent */ +int64_t EnergyEvseDelegate::GetMinimumChargeCurrent() +{ + return mMinimumChargeCurrent; +} + +CHIP_ERROR EnergyEvseDelegate::SetMinimumChargeCurrent(int64_t newValue) +{ + int64_t oldValue = mMinimumChargeCurrent; + + if (newValue >= kMaximumChargeCurrent) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mMinimumChargeCurrent = newValue; + if (oldValue != mMinimumChargeCurrent) + { + ChipLogDetail(AppServer, "MinimumChargeCurrent updated to %ld", static_cast(mMinimumChargeCurrent)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, MinimumChargeCurrent::Id); + } + return CHIP_NO_ERROR; +} + +/* MaximumChargeCurrent */ +int64_t EnergyEvseDelegate::GetMaximumChargeCurrent() +{ + return mMaximumChargeCurrent; +} + +CHIP_ERROR EnergyEvseDelegate::SetMaximumChargeCurrent(int64_t newValue) +{ + int64_t oldValue = mMaximumChargeCurrent; + + if (newValue >= kMaximumChargeCurrent) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mMaximumChargeCurrent = newValue; + if (oldValue != mMaximumChargeCurrent) + { + ChipLogDetail(AppServer, "MaximumChargeCurrent updated to %ld", static_cast(mMaximumChargeCurrent)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, MaximumChargeCurrent::Id); + } + return CHIP_NO_ERROR; +} + +/* MaximumDischargeCurrent */ +int64_t EnergyEvseDelegate::GetMaximumDischargeCurrent() +{ + return mMaximumDischargeCurrent; +} + +CHIP_ERROR EnergyEvseDelegate::SetMaximumDischargeCurrent(int64_t newValue) +{ + int64_t oldValue = mMaximumDischargeCurrent; + + if (newValue >= kMaximumChargeCurrent) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mMaximumDischargeCurrent = newValue; + if (oldValue != mMaximumDischargeCurrent) + { + ChipLogDetail(AppServer, "MaximumDischargeCurrent updated to %ld", static_cast(mMaximumDischargeCurrent)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, MaximumDischargeCurrent::Id); + } + return CHIP_NO_ERROR; +} + +/* UserMaximumChargeCurrent */ +int64_t EnergyEvseDelegate::GetUserMaximumChargeCurrent() +{ + return mUserMaximumChargeCurrent; +} + +CHIP_ERROR EnergyEvseDelegate::SetUserMaximumChargeCurrent(int64_t newValue) +{ + if ((newValue < 0) || (newValue > kMaximumChargeCurrent)) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + int64_t oldValue = mUserMaximumChargeCurrent; + mUserMaximumChargeCurrent = newValue; + if (oldValue != newValue) + { + ChipLogDetail(AppServer, "UserMaximumChargeCurrent updated to %ld", static_cast(mUserMaximumChargeCurrent)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, UserMaximumChargeCurrent::Id); + } + + return CHIP_NO_ERROR; +} + +/* RandomizationDelayWindow */ +uint32_t EnergyEvseDelegate::GetRandomizationDelayWindow() +{ + return mRandomizationDelayWindow; +} + +CHIP_ERROR EnergyEvseDelegate::SetRandomizationDelayWindow(uint32_t newValue) +{ + uint32_t oldValue = mRandomizationDelayWindow; + if (newValue > kMaxRandomizationDelayWindow) + { + return CHIP_IM_GLOBAL_STATUS(ConstraintError); + } + + mRandomizationDelayWindow = newValue; + if (oldValue != newValue) + { + ChipLogDetail(AppServer, "RandomizationDelayWindow updated to %lu", + static_cast(mRandomizationDelayWindow)); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, RandomizationDelayWindow::Id); + } + return CHIP_NO_ERROR; +} + +/* PREF attributes */ +uint8_t EnergyEvseDelegate::GetNumberOfWeeklyTargets() +{ + return mNumberOfWeeklyTargets; +} +uint8_t EnergyEvseDelegate::GetNumberOfDailyTargets() +{ + return mNumberOfDailyTargets; +} +DataModel::Nullable EnergyEvseDelegate::GetNextChargeStartTime() +{ + return mNextChargeStartTime; +} +DataModel::Nullable EnergyEvseDelegate::GetNextChargeTargetTime() +{ + return mNextChargeTargetTime; +} +DataModel::Nullable EnergyEvseDelegate::GetNextChargeRequiredEnergy() +{ + return mNextChargeRequiredEnergy; +} +DataModel::Nullable EnergyEvseDelegate::GetNextChargeTargetSoC() +{ + return mNextChargeTargetSoC; +} + +/* ApproximateEVEfficiency */ +DataModel::Nullable EnergyEvseDelegate::GetApproximateEVEfficiency() +{ + return mApproximateEVEfficiency; +} + +CHIP_ERROR EnergyEvseDelegate::SetApproximateEVEfficiency(uint16_t newValue) +{ + DataModel::Nullable oldValue = mApproximateEVEfficiency; + + mApproximateEVEfficiency = MakeNullable(newValue); + if ((oldValue.IsNull()) || (oldValue.Value() != newValue)) + { + ChipLogDetail(AppServer, "ApproximateEVEfficiency updated to %d", mApproximateEVEfficiency.Value()); + MatterReportingAttributeChangeCallback(mEndpointId, EnergyEvse::Id, ApproximateEVEfficiency::Id); + } + + return CHIP_NO_ERROR; +} + +/* SOC attributes */ +DataModel::Nullable EnergyEvseDelegate::GetStateOfCharge() +{ + return mStateOfCharge; +} +DataModel::Nullable EnergyEvseDelegate::GetBatteryCapacity() +{ + return mBatteryCapacity; +} + +/* PNC attributes*/ +DataModel::Nullable EnergyEvseDelegate::GetVehicleID() +{ + return mVehicleID; +} + +/* Session SESS attributes */ +DataModel::Nullable EnergyEvseDelegate::GetSessionID() +{ + return mSessionID; +} +DataModel::Nullable EnergyEvseDelegate::GetSessionDuration() +{ + return mSessionDuration; +} +DataModel::Nullable EnergyEvseDelegate::GetSessionEnergyCharged() +{ + return mSessionEnergyCharged; +} +DataModel::Nullable EnergyEvseDelegate::GetSessionEnergyDischarged() +{ + return mSessionEnergyDischarged; +} diff --git a/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp b/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp new file mode 100644 index 00000000000000..0d84d8856212e0 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp @@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::EnergyEvse; + +CHIP_ERROR EnergyEvseManager::Init() +{ + return Instance::Init(); +} + +void EnergyEvseManager::Shutdown() +{ + Instance::Shutdown(); +} diff --git a/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp new file mode 100644 index 00000000000000..a0773de104c187 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using namespace chip; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::EnergyEvse; + +static EnergyEvseDelegate * gDelegate = nullptr; +static EnergyEvseManager * gInstance = nullptr; + +void emberAfEnergyEvseClusterInitCallback(chip::EndpointId endpointId) +{ + VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. + VerifyOrDie(gInstance == nullptr); + gDelegate = new EnergyEvseDelegate(); + if (gDelegate != nullptr) + { + gInstance = + new EnergyEvseManager(endpointId, *gDelegate, + BitMask( + EnergyEvse::Feature::kChargingPreferences, EnergyEvse::Feature::kPlugAndCharge, + EnergyEvse::Feature::kRfid, EnergyEvse::Feature::kSoCReporting, EnergyEvse::Feature::kV2x), + BitMask(OptionalAttributes::kSupportsUserMaximumChargingCurrent, + OptionalAttributes::kSupportsRandomizationWindow, + OptionalAttributes::kSupportsApproximateEvEfficiency), + BitMask(OptionalCommands::kSupportsStartDiagnostics)); + + gInstance->Init(); /* Register Attribute & Command handlers */ + } +} diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index 07052e123757cd..f3c6a54854c475 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -156,6 +156,9 @@ list( ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp + ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp + ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp + ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp diff --git a/examples/all-clusters-app/asr/BUILD.gn b/examples/all-clusters-app/asr/BUILD.gn index 9447bbe9d3c45d..75c4a3171cfd4a 100755 --- a/examples/all-clusters-app/asr/BUILD.gn +++ b/examples/all-clusters-app/asr/BUILD.gn @@ -71,9 +71,12 @@ asr_executable("clusters_app") { output_name = "chip-asr-clusters-example.out" sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn index 6c991abac181a1..ad07e2c7a0da32 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn @@ -75,10 +75,13 @@ ti_simplelink_executable("all-clusters-app") { output_name = "chip-${ti_simplelink_board}-all-clusters-example.out" sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", diff --git a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn index 9b5fd07f4b6893..c35afae97aabba 100644 --- a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn +++ b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn @@ -78,10 +78,13 @@ ti_simplelink_executable("all-clusters-app") { output_name = "chip-${ti_simplelink_board}-all-clusters-example.out" sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 1be7ef7cd6c842..5680634c786678 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -72,6 +72,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/icd-management-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-evse-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" diff --git a/examples/all-clusters-app/infineon/psoc6/BUILD.gn b/examples/all-clusters-app/infineon/psoc6/BUILD.gn index d61814767374d2..b99dc84405e841 100644 --- a/examples/all-clusters-app/infineon/psoc6/BUILD.gn +++ b/examples/all-clusters-app/infineon/psoc6/BUILD.gn @@ -107,9 +107,12 @@ psoc6_executable("clusters_app") { output_name = "chip-psoc6-clusters-example.out" sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index cfe028c7af7cc5..b3eb61c29f875a 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -21,12 +21,15 @@ import("${chip_root}/src/platform/device.gni") source_set("chip-all-clusters-common") { sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-alarm-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-mode.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-mode.cpp", diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index 486901342dbb08..79a48c85938f78 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -63,6 +63,9 @@ target_sources(${APP_TARGET} PRIVATE ${ALL_CLUSTERS_COMMON}/src/air-quality-instance.cpp ${ALL_CLUSTERS_COMMON}/src/concentration-measurement-instances.cpp ${ALL_CLUSTERS_COMMON}/src/fan-stub.cpp + ${ALL_CLUSTERS_COMMON}/src/EnergyEvseDelegateImpl.cpp + ${ALL_CLUSTERS_COMMON}/src/EnergyEvseManager.cpp + ${ALL_CLUSTERS_COMMON}/src/energy-evse-stub.cpp ${ALL_CLUSTERS_COMMON}/src/resource-monitoring-delegates.cpp ${ALL_CLUSTERS_COMMON}/src/smco-stub.cpp ${ALL_CLUSTERS_COMMON}/src/static-supported-modes-manager.cpp diff --git a/examples/all-clusters-app/nrfconnect/CMakeLists.txt b/examples/all-clusters-app/nrfconnect/CMakeLists.txt index 029210cbf28720..72b93e0647724c 100644 --- a/examples/all-clusters-app/nrfconnect/CMakeLists.txt +++ b/examples/all-clusters-app/nrfconnect/CMakeLists.txt @@ -61,6 +61,9 @@ target_sources(app PRIVATE ${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-temperature-levels.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/fan-stub.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/EnergyEvseDelegateImpl.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/EnergyEvseManager.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/energy-evse-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/air-quality-instance.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/concentration-measurement-instances.cpp diff --git a/examples/all-clusters-app/nxp/mw320/BUILD.gn b/examples/all-clusters-app/nxp/mw320/BUILD.gn index f7f415961a7481..ab7be5a04d64c1 100644 --- a/examples/all-clusters-app/nxp/mw320/BUILD.gn +++ b/examples/all-clusters-app/nxp/mw320/BUILD.gn @@ -74,9 +74,12 @@ mw320_executable("shell_mw320") { "${chip_root}/examples/all-clusters-app/nxp/mw320/include", ] sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", diff --git a/examples/all-clusters-app/nxp/rt/rw61x/BUILD.gn b/examples/all-clusters-app/nxp/rt/rw61x/BUILD.gn index 4c0ccba283249b..6f167c92ce5be2 100644 --- a/examples/all-clusters-app/nxp/rt/rw61x/BUILD.gn +++ b/examples/all-clusters-app/nxp/rt/rw61x/BUILD.gn @@ -117,7 +117,10 @@ rt_executable("all_cluster_app") { if (nxp_device_type == "all-clusters") { defines += [ "DEVICE_TYPE_ALL_CLUSTERS" ] sources += [ + "${chip_root}/examples/${app_common_folder}/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/${app_common_folder}/src/EnergyEvseManager.cpp", "${chip_root}/examples/${app_common_folder}/src/bridged-actions-stub.cpp", + "${chip_root}/examples/${app_common_folder}/src/energy-evse-stub.cpp", "${chip_root}/examples/${app_common_folder}/src/smco-stub.cpp", "${chip_root}/examples/${app_common_folder}/src/static-supported-modes-manager.cpp", ] diff --git a/examples/all-clusters-app/openiotsdk/CMakeLists.txt b/examples/all-clusters-app/openiotsdk/CMakeLists.txt index 6b2e7cc87b3157..dce8295b300cb4 100644 --- a/examples/all-clusters-app/openiotsdk/CMakeLists.txt +++ b/examples/all-clusters-app/openiotsdk/CMakeLists.txt @@ -57,6 +57,9 @@ target_sources(${APP_TARGET} ${ALL_CLUSTERS_COMMON}/src/air-quality-instance.cpp ${ALL_CLUSTERS_COMMON}/src/concentration-measurement-instances.cpp ${ALL_CLUSTERS_COMMON}/src/fan-stub.cpp + ${ALL_CLUSTERS_COMMON}/src/EnergyEvseDelegateImpl.cpp + ${ALL_CLUSTERS_COMMON}/src/EnergyEvseManager.cpp + ${ALL_CLUSTERS_COMMON}/src/energy-evse-stub.cpp ${ALL_CLUSTERS_COMMON}/src/resource-monitoring-delegates.cpp ${ALL_CLUSTERS_COMMON}/src/static-supported-modes-manager.cpp ${ALL_CLUSTERS_COMMON}/src/binding-handler.cpp diff --git a/examples/all-clusters-app/telink/CMakeLists.txt b/examples/all-clusters-app/telink/CMakeLists.txt index 46b7b72960b65b..fa279aa4c8a90f 100644 --- a/examples/all-clusters-app/telink/CMakeLists.txt +++ b/examples/all-clusters-app/telink/CMakeLists.txt @@ -84,6 +84,9 @@ target_sources(app PRIVATE ${ALL_CLUSTERS_COMMON_DIR}/src/air-quality-instance.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/concentration-measurement-instances.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/fan-stub.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/EnergyEvseDelegateImpl.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/EnergyEvseManager.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/energy-evse-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/resource-monitoring-delegates.cpp ${TELINK_COMMON}/common/src/mainCommon.cpp ${TELINK_COMMON}/common/src/AppTaskCommon.cpp diff --git a/examples/all-clusters-app/tizen/BUILD.gn b/examples/all-clusters-app/tizen/BUILD.gn index 1f40d96500c012..6960ec6aa6d516 100644 --- a/examples/all-clusters-app/tizen/BUILD.gn +++ b/examples/all-clusters-app/tizen/BUILD.gn @@ -23,10 +23,13 @@ assert(chip_build_tools) source_set("chip-all-clusters-common") { sources = [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/resource-monitoring-delegates.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", diff --git a/examples/shell/shell_common/BUILD.gn b/examples/shell/shell_common/BUILD.gn index 2cbc8900f9353a..b870628717d8e5 100644 --- a/examples/shell/shell_common/BUILD.gn +++ b/examples/shell/shell_common/BUILD.gn @@ -64,7 +64,10 @@ static_library("shell_common") { import("${chip_root}/src/app/chip_data_model.gni") sources += [ + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseDelegateImpl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/EnergyEvseManager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp", diff --git a/scripts/py_matter_idl/matter_idl/generators/type_definitions.py b/scripts/py_matter_idl/matter_idl/generators/type_definitions.py index 5f80f1e5ddf998..4f9fa56779042b 100644 --- a/scripts/py_matter_idl/matter_idl/generators/type_definitions.py +++ b/scripts/py_matter_idl/matter_idl/generators/type_definitions.py @@ -188,6 +188,7 @@ def is_struct(self) -> bool: # Derived types # Specification describes them in section '7.19.2. Derived Data Types' "action_id": BasicInteger(idl_name="action_id", byte_count=1, is_signed=False), + "amperage_ma": BasicInteger(idl_name="amperage_ma", byte_count=8, is_signed=True), "attrib_id": BasicInteger(idl_name="attrib_id", byte_count=4, is_signed=False), "cluster_id": BasicInteger(idl_name="cluster_id", byte_count=4, is_signed=False), "command_id": BasicInteger(idl_name="command_id", byte_count=4, is_signed=False), @@ -196,6 +197,7 @@ def is_struct(self) -> bool: "devtype_id": BasicInteger(idl_name="devtype_id", byte_count=4, is_signed=False), "elapsed_s": BasicInteger(idl_name="elapsed_s", byte_count=4, is_signed=False), "endpoint_no": BasicInteger(idl_name="endpoint_no", byte_count=2, is_signed=False), + "energy_mwh": BasicInteger(idl_name="energy_mwh", byte_count=8, is_signed=True), "entry_idx": BasicInteger(idl_name="entry_idx", byte_count=2, is_signed=False), "epoch_s": BasicInteger(idl_name="epoch_s", byte_count=4, is_signed=False), "epoch_us": BasicInteger(idl_name="epoch_us", byte_count=8, is_signed=False), @@ -210,6 +212,7 @@ def is_struct(self) -> bool: "percent": BasicInteger(idl_name="percent", byte_count=1, is_signed=False), "percent100ths": BasicInteger(idl_name="percent100ths", byte_count=2, is_signed=False), "posix_ms": BasicInteger(idl_name="posix_ms", byte_count=8, is_signed=False), + "power_mw": BasicInteger(idl_name="power_mw", byte_count=8, is_signed=True), "priority": BasicInteger(idl_name="priority", byte_count=1, is_signed=False), "semtag": BasicInteger(idl_name="semtag", byte_count=4, is_signed=False), "status": BasicInteger(idl_name="status", byte_count=1, is_signed=False), @@ -220,6 +223,7 @@ def is_struct(self) -> bool: "tod": BasicInteger(idl_name="tod", byte_count=4, is_signed=False), "trans_id": BasicInteger(idl_name="trans_id", byte_count=4, is_signed=False), "vendor_id": BasicInteger(idl_name="vendor_id", byte_count=2, is_signed=False), + "voltage_mv": BasicInteger(idl_name="voltage_mv", byte_count=8, is_signed=True), } diff --git a/src/app/clusters/energy-evse-server/energy-evse-server.cpp b/src/app/clusters/energy-evse-server/energy-evse-server.cpp new file mode 100644 index 00000000000000..60f9e24be0f962 --- /dev/null +++ b/src/app/clusters/energy-evse-server/energy-evse-server.cpp @@ -0,0 +1,395 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "energy-evse-server.h" + +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::EnergyEvse; +using namespace chip::app::Clusters::EnergyEvse::Attributes; +using chip::Protocols::InteractionModel::Status; + +namespace chip { +namespace app { +namespace Clusters { +namespace EnergyEvse { + +CHIP_ERROR Instance::Init() +{ + ReturnErrorOnFailure(InteractionModelEngine::GetInstance()->RegisterCommandHandler(this)); + VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); + + return CHIP_NO_ERROR; +} + +void Instance::Shutdown() +{ + InteractionModelEngine::GetInstance()->UnregisterCommandHandler(this); + unregisterAttributeAccessOverride(this); +} + +bool Instance::HasFeature(Feature aFeature) const +{ + return mFeature.Has(aFeature); +} + +bool Instance::SupportsOptAttr(OptionalAttributes aOptionalAttrs) const +{ + return mOptionalAttrs.Has(aOptionalAttrs); +} + +bool Instance::SupportsOptCmd(OptionalCommands aOptionalCmds) const +{ + return mOptionalCmds.Has(aOptionalCmds); +} + +// AttributeAccessInterface +CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + switch (aPath.mAttributeId) + { + case State::Id: + return aEncoder.Encode(mDelegate.GetState()); + case SupplyState::Id: + return aEncoder.Encode(mDelegate.GetSupplyState()); + case FaultState::Id: + return aEncoder.Encode(mDelegate.GetFaultState()); + case ChargingEnabledUntil::Id: + return aEncoder.Encode(mDelegate.GetChargingEnabledUntil()); + case DischargingEnabledUntil::Id: + /* V2X */ + return aEncoder.Encode(mDelegate.GetDischargingEnabledUntil()); + case CircuitCapacity::Id: + return aEncoder.Encode(mDelegate.GetCircuitCapacity()); + case MinimumChargeCurrent::Id: + return aEncoder.Encode(mDelegate.GetMinimumChargeCurrent()); + case MaximumChargeCurrent::Id: + return aEncoder.Encode(mDelegate.GetMaximumChargeCurrent()); + case MaximumDischargeCurrent::Id: + /* V2X */ + return aEncoder.Encode(mDelegate.GetMaximumDischargeCurrent()); + + case UserMaximumChargeCurrent::Id: + return aEncoder.Encode(mDelegate.GetUserMaximumChargeCurrent()); + case RandomizationDelayWindow::Id: + /* Optional */ + return aEncoder.Encode(mDelegate.GetRandomizationDelayWindow()); + /* PREF - ChargingPreferences attributes */ + case NumberOfWeeklyTargets::Id: + return aEncoder.Encode(mDelegate.GetNumberOfWeeklyTargets()); + case NumberOfDailyTargets::Id: + return aEncoder.Encode(mDelegate.GetNumberOfDailyTargets()); + case NextChargeStartTime::Id: + return aEncoder.Encode(mDelegate.GetNextChargeStartTime()); + case NextChargeTargetTime::Id: + return aEncoder.Encode(mDelegate.GetNextChargeTargetTime()); + case NextChargeRequiredEnergy::Id: + return aEncoder.Encode(mDelegate.GetNextChargeRequiredEnergy()); + case NextChargeTargetSoC::Id: + return aEncoder.Encode(mDelegate.GetNextChargeTargetSoC()); + case ApproximateEVEfficiency::Id: + return aEncoder.Encode(mDelegate.GetApproximateEVEfficiency()); + /* SOC attributes */ + case StateOfCharge::Id: + return aEncoder.Encode(mDelegate.GetStateOfCharge()); + case BatteryCapacity::Id: + return aEncoder.Encode(mDelegate.GetBatteryCapacity()); + /* PNC attributes*/ + case VehicleID::Id: + return aEncoder.Encode(mDelegate.GetVehicleID()); + /* Session SESS attributes */ + case SessionID::Id: + return aEncoder.Encode(mDelegate.GetSessionID()); + case SessionDuration::Id: + return aEncoder.Encode(mDelegate.GetSessionDuration()); + case SessionEnergyCharged::Id: + return aEncoder.Encode(mDelegate.GetSessionEnergyCharged()); + case SessionEnergyDischarged::Id: + return aEncoder.Encode(mDelegate.GetSessionEnergyDischarged()); + } + /* Allow all other unhandled attributes to fall through to Ember */ + return CHIP_NO_ERROR; +} + +CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) +{ + switch (aPath.mAttributeId) + { + case UserMaximumChargeCurrent::Id: { + // Optional Attribute + if (!SupportsOptAttr(OptionalAttributes::kSupportsUserMaximumChargingCurrent)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + + int64_t newValue; + ReturnErrorOnFailure(aDecoder.Decode(newValue)); + ReturnErrorOnFailure(mDelegate.SetUserMaximumChargeCurrent(newValue)); + return CHIP_NO_ERROR; + } + case RandomizationDelayWindow::Id: { + // Optional Attribute + if (!SupportsOptAttr(OptionalAttributes::kSupportsRandomizationWindow)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + uint32_t newValue; + ReturnErrorOnFailure(aDecoder.Decode(newValue)); + ReturnErrorOnFailure(mDelegate.SetRandomizationDelayWindow(newValue)); + return CHIP_NO_ERROR; + } + case ApproximateEVEfficiency::Id: { + // Optional Attribute if ChargingPreferences is supported + if ((!HasFeature(Feature::kChargingPreferences)) || + (!SupportsOptAttr(OptionalAttributes::kSupportsApproximateEvEfficiency))) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + uint16_t newValue; + ReturnErrorOnFailure(aDecoder.Decode(newValue)); + ReturnErrorOnFailure(mDelegate.SetApproximateEVEfficiency(newValue)); + return CHIP_NO_ERROR; + } + + default: + // Unknown attribute; return error. None of the other attributes for + // this cluster are writable, so should not be ending up in this code to + // start with. + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } +} + +// CommandHandlerInterface +CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context) +{ + using namespace Commands; + + for (auto && cmd : { + Disable::Id, + EnableCharging::Id, + }) + { + VerifyOrExit(callback(cmd, context) == Loop::Continue, /**/); + } + + if (HasFeature(Feature::kV2x)) + { + VerifyOrExit(callback(EnableDischarging::Id, context) == Loop::Continue, /**/); + } + + if (HasFeature(Feature::kChargingPreferences)) + { + for (auto && cmd : { + SetTargets::Id, + GetTargets::Id, + ClearTargets::Id, + }) + { + VerifyOrExit(callback(cmd, context) == Loop::Continue, /**/); + } + } + + if (SupportsOptCmd(OptionalCommands::kSupportsStartDiagnostics)) + { + callback(StartDiagnostics::Id, context); + } + +exit: + return CHIP_NO_ERROR; +} + +void Instance::InvokeCommand(HandlerContext & handlerContext) +{ + using namespace Commands; + + switch (handlerContext.mRequestPath.mCommandId) + { + case Disable::Id: + HandleCommand( + handlerContext, [this](HandlerContext & ctx, const auto & commandData) { HandleDisable(ctx, commandData); }); + return; + case EnableCharging::Id: + HandleCommand( + handlerContext, [this](HandlerContext & ctx, const auto & commandData) { HandleEnableCharging(ctx, commandData); }); + return; + case EnableDischarging::Id: + if (!HasFeature(Feature::kV2x)) + { + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); + } + else + { + HandleCommand(handlerContext, [this](HandlerContext & ctx, const auto & commandData) { + HandleEnableDischarging(ctx, commandData); + }); + } + return; + case StartDiagnostics::Id: + if (!SupportsOptCmd(OptionalCommands::kSupportsStartDiagnostics)) + { + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); + } + else + { + HandleCommand(handlerContext, [this](HandlerContext & ctx, const auto & commandData) { + HandleStartDiagnostics(ctx, commandData); + }); + } + return; + case SetTargets::Id: + if (!HasFeature(Feature::kChargingPreferences)) + { + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); + } + else + { + HandleCommand( + handlerContext, [this](HandlerContext & ctx, const auto & commandData) { HandleSetTargets(ctx, commandData); }); + } + return; + case GetTargets::Id: + if (!HasFeature(Feature::kChargingPreferences)) + { + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); + } + else + { + HandleCommand( + handlerContext, [this](HandlerContext & ctx, const auto & commandData) { HandleGetTargets(ctx, commandData); }); + } + return; + case ClearTargets::Id: + if (!HasFeature(Feature::kChargingPreferences)) + { + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); + } + else + { + HandleCommand( + handlerContext, [this](HandlerContext & ctx, const auto & commandData) { HandleClearTargets(ctx, commandData); }); + } + return; + } +} + +void Instance::HandleDisable(HandlerContext & ctx, const Commands::Disable::DecodableType & commandData) +{ + // No parameters for this command + // Call the delegate + Status status = mDelegate.Disable(); + + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); +} + +void Instance::HandleEnableCharging(HandlerContext & ctx, const Commands::EnableCharging::DecodableType & commandData) +{ + auto & chargingEnabledUntil = commandData.chargingEnabledUntil; + auto & minimumChargeCurrent = commandData.minimumChargeCurrent; + auto & maximumChargeCurrent = commandData.maximumChargeCurrent; + + if ((minimumChargeCurrent < kMinimumChargeCurrent) || (minimumChargeCurrent > kMaximumChargeCurrent)) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + if ((maximumChargeCurrent < kMinimumChargeCurrent) || (maximumChargeCurrent > kMaximumChargeCurrent)) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + if (minimumChargeCurrent > maximumChargeCurrent) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + // Call the delegate + Status status = mDelegate.EnableCharging(chargingEnabledUntil, minimumChargeCurrent, maximumChargeCurrent); + + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); +} + +void Instance::HandleEnableDischarging(HandlerContext & ctx, const Commands::EnableDischarging::DecodableType & commandData) +{ + + auto & dischargingEnabledUntil = commandData.dischargingEnabledUntil; + auto & maximumDischargeCurrent = commandData.maximumDischargeCurrent; + + if ((maximumDischargeCurrent < kMinimumChargeCurrent) || (maximumDischargeCurrent > kMaximumChargeCurrent)) + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); + return; + } + + // Call the delegate + Status status = mDelegate.EnableDischarging(dischargingEnabledUntil, maximumDischargeCurrent); + + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); +} +void Instance::HandleStartDiagnostics(HandlerContext & ctx, const Commands::StartDiagnostics::DecodableType & commandData) +{ + // No parameters for this command + // Call the delegate + Status status = mDelegate.StartDiagnostics(); + + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); +} + +void Instance::HandleSetTargets(HandlerContext & ctx, const Commands::SetTargets::DecodableType & commandData) +{ + // Call the delegate + // TODO + // Status status = mDelegate.SetTargets(); + Status status = Status::UnsupportedCommand; + + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); +} +void Instance::HandleGetTargets(HandlerContext & ctx, const Commands::GetTargets::DecodableType & commandData) +{ + // Call the delegate + // TODO + // Status status = mDelegate.GetTargets(); + Status status = Status::UnsupportedCommand; + + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); +} +void Instance::HandleClearTargets(HandlerContext & ctx, const Commands::ClearTargets::DecodableType & commandData) +{ + // Call the delegate + // TODO + // Status status = mDelegate.ClearTargets(); + Status status = Status::UnsupportedCommand; + + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); +} + +} // namespace EnergyEvse +} // namespace Clusters +} // namespace app +} // namespace chip + +// ----------------------------------------------------------------------------- +// Plugin initialization + +void MatterEnergyEvsePluginServerInitCallback() {} diff --git a/src/app/clusters/energy-evse-server/energy-evse-server.h b/src/app/clusters/energy-evse-server/energy-evse-server.h new file mode 100644 index 00000000000000..5df2f0149eb1ed --- /dev/null +++ b/src/app/clusters/energy-evse-server/energy-evse-server.h @@ -0,0 +1,186 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace EnergyEvse { + +// Spec-defined constraints +constexpr int64_t kMinimumChargeCurrent = 0; +constexpr int64_t kMaximumChargeCurrent = 80000; +constexpr uint32_t kMaxRandomizationDelayWindow = 86400; + +using chip::Protocols::InteractionModel::Status; +/** @brief + * Defines methods for implementing application-specific logic for the EVSE Management Cluster. + */ +class Delegate +{ +public: + virtual ~Delegate() = default; + + void SetEndpointId(EndpointId aEndpoint) { mEndpointId = aEndpoint; } + + /** + * @brief Delegate should implement a handler to disable the EVSE. + * It should report Status::Success if successful and may + * return other Status codes if it fails + */ + virtual Status Disable() = 0; + + /** + * @brief Delegate should implement a handler to enable EVSE Charging. + * It should report Status::Success if successful and may + * return other Status codes if it fails + */ + virtual Status EnableCharging(const DataModel::Nullable & enableChargeTime, const int64_t & minimumChargeCurrent, + const int64_t & maximumChargeCurrent) = 0; + + /** + * @brief Delegate should implement a handler to enable EVSE Discharging. + * It should report Status::Success if successful and may + * return other Status codes if it fails + */ + virtual Status EnableDischarging(const DataModel::Nullable & enableDischargeTime, + const int64_t & maximumDischargeCurrent) = 0; + + /** + * @brief Delegate should implement a handler to enable EVSE Diagnostics. + * It should report Status::Success if successful and may + * return other Status codes if it fails + */ + virtual Status StartDiagnostics() = 0; + + // ------------------------------------------------------------------ + // Get attribute methods + virtual StateEnum GetState() = 0; + virtual SupplyStateEnum GetSupplyState() = 0; + virtual FaultStateEnum GetFaultState() = 0; + virtual DataModel::Nullable GetChargingEnabledUntil() = 0; + virtual DataModel::Nullable GetDischargingEnabledUntil() = 0; + virtual int64_t GetCircuitCapacity() = 0; + virtual int64_t GetMinimumChargeCurrent() = 0; + virtual int64_t GetMaximumChargeCurrent() = 0; + virtual int64_t GetMaximumDischargeCurrent() = 0; + virtual int64_t GetUserMaximumChargeCurrent() = 0; + virtual uint32_t GetRandomizationDelayWindow() = 0; + /* PREF attributes */ + virtual uint8_t GetNumberOfWeeklyTargets() = 0; + virtual uint8_t GetNumberOfDailyTargets() = 0; + virtual DataModel::Nullable GetNextChargeStartTime() = 0; + virtual DataModel::Nullable GetNextChargeTargetTime() = 0; + virtual DataModel::Nullable GetNextChargeRequiredEnergy() = 0; + virtual DataModel::Nullable GetNextChargeTargetSoC() = 0; + virtual DataModel::Nullable GetApproximateEVEfficiency() = 0; + + /* SOC attributes */ + virtual DataModel::Nullable GetStateOfCharge() = 0; + virtual DataModel::Nullable GetBatteryCapacity() = 0; + + /* PNC attributes*/ + virtual DataModel::Nullable GetVehicleID() = 0; + + /* Session SESS attributes */ + virtual DataModel::Nullable GetSessionID() = 0; + virtual DataModel::Nullable GetSessionDuration() = 0; + virtual DataModel::Nullable GetSessionEnergyCharged() = 0; + virtual DataModel::Nullable GetSessionEnergyDischarged() = 0; + + // ------------------------------------------------------------------ + // Set attribute methods + virtual CHIP_ERROR SetUserMaximumChargeCurrent(int64_t aNewValue) = 0; + virtual CHIP_ERROR SetRandomizationDelayWindow(uint32_t aNewValue) = 0; + virtual CHIP_ERROR SetApproximateEVEfficiency(uint16_t aNewValue) = 0; + +protected: + EndpointId mEndpointId = 0; +}; + +enum class OptionalAttributes : uint32_t +{ + kSupportsUserMaximumChargingCurrent = 0x1, + kSupportsRandomizationWindow = 0x2, + kSupportsApproximateEvEfficiency = 0x4 +}; + +enum class OptionalCommands : uint32_t +{ + kSupportsStartDiagnostics = 0x1 +}; + +class Instance : public AttributeAccessInterface, public CommandHandlerInterface +{ +public: + Instance(EndpointId aEndpointId, Delegate & aDelegate, Feature aFeature, OptionalAttributes aOptionalAttrs, + OptionalCommands aOptionalCmds) : + AttributeAccessInterface(MakeOptional(aEndpointId), Id), + CommandHandlerInterface(MakeOptional(aEndpointId), Id), mDelegate(aDelegate), mFeature(aFeature), + mOptionalAttrs(aOptionalAttrs), mOptionalCmds(aOptionalCmds) + { + /* set the base class delegates endpointId */ + mDelegate.SetEndpointId(aEndpointId); + } + ~Instance() { Shutdown(); } + + CHIP_ERROR Init(); + void Shutdown(); + + bool HasFeature(Feature aFeature) const; + bool SupportsOptAttr(OptionalAttributes aOptionalAttrs) const; + bool SupportsOptCmd(OptionalCommands aOptionalCmds) const; + +private: + Delegate & mDelegate; + BitMask mFeature; + BitMask mOptionalAttrs; + BitMask mOptionalCmds; + + // AttributeAccessInterface + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override; + + // CommandHandlerInterface + void InvokeCommand(HandlerContext & handlerContext) override; + CHIP_ERROR EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context) override; + + void HandleDisable(HandlerContext & ctx, const Commands::Disable::DecodableType & commandData); + void HandleEnableCharging(HandlerContext & ctx, const Commands::EnableCharging::DecodableType & commandData); + void HandleEnableDischarging(HandlerContext & ctx, const Commands::EnableDischarging::DecodableType & commandData); + void HandleStartDiagnostics(HandlerContext & ctx, const Commands::StartDiagnostics::DecodableType & commandData); + void HandleSetTargets(HandlerContext & ctx, const Commands::SetTargets::DecodableType & commandData); + void HandleGetTargets(HandlerContext & ctx, const Commands::GetTargets::DecodableType & commandData); + void HandleClearTargets(HandlerContext & ctx, const Commands::ClearTargets::DecodableType & commandData); +}; + +} // namespace EnergyEvse +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index de08342c4f18f6..6a3c6fd5b0ada0 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -123,6 +123,12 @@ EmberAfAttributeType BaseType(EmberAfAttributeType type) "chip::DataVersion is expected to be uint32_t, change this when necessary"); return ZCL_INT32U_ATTRIBUTE_TYPE; + case ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE: // Amperage milliamps + case ZCL_ENERGY_MWH_ATTRIBUTE_TYPE: // Energy milliwatt-hours + case ZCL_POWER_MW_ATTRIBUTE_TYPE: // Power milliwatts + case ZCL_VOLTAGE_MV_ATTRIBUTE_TYPE: // Voltage millivolts + return ZCL_INT64S_ATTRIBUTE_TYPE; + case ZCL_EVENT_NO_ATTRIBUTE_TYPE: // Event Number case ZCL_FABRIC_ID_ATTRIBUTE_TYPE: // Fabric Id case ZCL_NODE_ID_ATTRIBUTE_TYPE: // Node Id diff --git a/src/app/zap-templates/common/override.js b/src/app/zap-templates/common/override.js index 98420cdabb1fda..6930a0479f0fb7 100644 --- a/src/app/zap-templates/common/override.js +++ b/src/app/zap-templates/common/override.js @@ -74,6 +74,11 @@ function atomicType(arg) return 'chip::Percent'; case 'percent100ths': return 'chip::Percent100ths'; + case 'power_mw': + case 'amperage_ma': + case 'voltage_mv': + case 'energy_mwh': + return 'int64_t'; case 'epoch_us': case 'systime_us': case 'posix_ms': diff --git a/src/app/zap-templates/zcl/data-model/chip/chip-types.xml b/src/app/zap-templates/zcl/data-model/chip/chip-types.xml index ffbf74cb78804c..02d81623cc3394 100644 --- a/src/app/zap-templates/zcl/data-model/chip/chip-types.xml +++ b/src/app/zap-templates/zcl/data-model/chip/chip-types.xml @@ -55,6 +55,11 @@ limitations under the License. + + + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/energy-evse-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/energy-evse-cluster.xml index 8eed118f9ef953..f8925c73d7ce3c 100644 --- a/src/app/zap-templates/zcl/data-model/chip/energy-evse-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/energy-evse-cluster.xml @@ -69,9 +69,9 @@ limitations under the License. - + - + Energy EVSE @@ -88,15 +88,15 @@ limitations under the License. State SupplyState FaultState - ChargingEnabledUntil + ChargingEnabledUntil - DischargingEnabledUntil - CircuitCapacity - MinimumChargeCurrent - MaximumChargeCurrent + DischargingEnabledUntil + CircuitCapacity + MinimumChargeCurrent + MaximumChargeCurrent - MaximumDischargeCurrent - + MaximumDischargeCurrent + UserMaximumChargeCurrent @@ -115,7 +115,7 @@ limitations under the License. NextChargeTargetTime - NextChargeRequiredEnergy + NextChargeRequiredEnergy NextChargeTargetSoC @@ -127,48 +127,41 @@ limitations under the License. StateOfCharge - BatteryCapacity + BatteryCapacity VehicleID - SessionID - SessionDuration - SessionEnergyCharged + SessionID + SessionDuration + SessionEnergyCharged - SessionEnergyDischarged + SessionEnergyDischarged - Allows a client to disable the EVSE from charging and discharging. - - - + + Allows a client to enable the EVSE to charge an EV. - - + Allows a client to enable the EVSE to discharge an EV. - Allows a client to put the EVSE into a self-diagnostics mode. - Allows a client to set the user specified charging targets. - Allows a client to retrieve the user specified charging targets. - Allows a client to clear all stored charging targets. @@ -176,39 +169,39 @@ limitations under the License. The GetTargetsResponse is sent in response to the GetTargets Command. - + EVConnected - + - + EVNotDetected - + - - + + - + EnergyTransferStarted - + - + - + EnergyTransferStopped - + - + - + Fault - + - + RFID diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index b7b0f2c7acd16e..5a622d7e1820bd 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -4628,9 +4628,9 @@ provisional cluster EnergyEvse = 153 { } struct ChargingTargetStruct { - int16u targetTime = 0; + int16u targetTimeMinutesPastMidnight = 0; optional percent targetSoC = 1; - optional int64s addedEnergy = 2; + optional energy_mwh addedEnergy = 2; } info event EVConnected = 0 { @@ -4641,25 +4641,25 @@ provisional cluster EnergyEvse = 153 { int32u sessionID = 0; StateEnum state = 1; elapsed_s sessionDuration = 2; - int64s sessionEnergyCharged = 3; - optional int64s sessionEnergyDischarged = 4; + energy_mwh sessionEnergyCharged = 3; + optional energy_mwh sessionEnergyDischarged = 4; } info event EnergyTransferStarted = 2 { int32u sessionID = 0; StateEnum state = 1; - int64s maximumCurrent = 2; + amperage_ma maximumCurrent = 2; } info event EnergyTransferStopped = 3 { int32u sessionID = 0; StateEnum state = 1; EnergyTransferStoppedReasonEnum reason = 2; - int64s energyTransferred = 4; + energy_mwh energyTransferred = 4; } critical event Fault = 4 { - int32u sessionID = 0; + nullable int32u sessionID = 0; StateEnum state = 1; FaultStateEnum faultStatePreviousState = 2; FaultStateEnum faultStateCurrentState = 4; @@ -4674,26 +4674,26 @@ provisional cluster EnergyEvse = 153 { readonly attribute FaultStateEnum faultState = 2; readonly attribute nullable epoch_s chargingEnabledUntil = 3; readonly attribute optional nullable epoch_s dischargingEnabledUntil = 4; - readonly attribute int64s circuitCapacity = 5; - readonly attribute int64s minimumChargeCurrent = 6; - readonly attribute int64s maximumChargeCurrent = 7; - readonly attribute optional int64s maximumDischargeCurrent = 8; - attribute access(write: manage) optional int64s userMaximumChargeCurrent = 9; + readonly attribute amperage_ma circuitCapacity = 5; + readonly attribute amperage_ma minimumChargeCurrent = 6; + readonly attribute amperage_ma maximumChargeCurrent = 7; + readonly attribute optional amperage_ma maximumDischargeCurrent = 8; + attribute access(write: manage) optional amperage_ma userMaximumChargeCurrent = 9; attribute access(write: manage) optional elapsed_s randomizationDelayWindow = 10; readonly attribute optional int8u numberOfWeeklyTargets = 33; readonly attribute optional int8u numberOfDailyTargets = 34; readonly attribute optional nullable epoch_s nextChargeStartTime = 35; readonly attribute optional nullable epoch_s nextChargeTargetTime = 36; - readonly attribute optional nullable int64s nextChargeRequiredEnergy = 37; + readonly attribute optional nullable energy_mwh nextChargeRequiredEnergy = 37; readonly attribute optional nullable percent nextChargeTargetSoC = 38; attribute access(write: manage) optional nullable int16u approximateEVEfficiency = 39; readonly attribute optional nullable percent stateOfCharge = 48; - readonly attribute optional nullable int64s batteryCapacity = 49; + readonly attribute optional nullable energy_mwh batteryCapacity = 49; readonly attribute optional nullable char_string<32> vehicleID = 50; readonly attribute nullable int32u sessionID = 64; - readonly attribute elapsed_s sessionDuration = 65; - readonly attribute int64s sessionEnergyCharged = 66; - readonly attribute optional int64s sessionEnergyDischarged = 67; + readonly attribute nullable elapsed_s sessionDuration = 65; + readonly attribute nullable energy_mwh sessionEnergyCharged = 66; + readonly attribute optional nullable energy_mwh sessionEnergyDischarged = 67; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4708,13 +4708,13 @@ provisional cluster EnergyEvse = 153 { request struct EnableChargingRequest { nullable epoch_s chargingEnabledUntil = 0; - int64s minimumChargeCurrent = 1; - int64s maximumChargeCurrent = 2; + amperage_ma minimumChargeCurrent = 1; + amperage_ma maximumChargeCurrent = 2; } request struct EnableDischargingRequest { nullable epoch_s dischargingEnabledUntil = 0; - int64s maximumDischargeCurrent = 1; + amperage_ma maximumDischargeCurrent = 1; } request struct SetTargetsRequest { diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index fb41ede1f42920..b530fd8f277f05 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -428,6 +428,7 @@ "define": "ON_OFF_SWITCH_CONFIGURATION_CLUSTER", "side": "client", "enabled": 1, + "apiMaturity": "deprecated", "attributes": [ { "name": "ClusterRevision", @@ -562,6 +563,7 @@ "define": "BINARY_INPUT_BASIC_CLUSTER", "side": "client", "enabled": 1, + "apiMaturity": "deprecated", "attributes": [ { "name": "ClusterRevision", @@ -3484,6 +3486,7 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "client", "enabled": 1, + "apiMaturity": "deprecated", "commands": [ { "name": "BarrierControlGoToPercent", @@ -5108,6 +5111,7 @@ "define": "ELECTRICAL_MEASUREMENT_CLUSTER", "side": "client", "enabled": 1, + "apiMaturity": "deprecated", "attributes": [ { "name": "ClusterRevision", diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index 224dab357f761a..d4a978192119d9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -29927,6 +29927,18 @@ public interface SessionIDAttributeCallback extends BaseAttributeCallback { void onSuccess(@Nullable Long value); } + public interface SessionDurationAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface SessionEnergyChargedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + + public interface SessionEnergyDischargedAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Long value); + } + public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } @@ -30521,76 +30533,76 @@ public void onSuccess(byte[] tlv) { } public void readSessionDurationAttribute( - LongAttributeCallback callback) { + SessionDurationAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SESSION_DURATION_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } }, SESSION_DURATION_ATTRIBUTE_ID, true); } public void subscribeSessionDurationAttribute( - LongAttributeCallback callback, int minInterval, int maxInterval) { + SessionDurationAttributeCallback callback, int minInterval, int maxInterval) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SESSION_DURATION_ATTRIBUTE_ID); subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } }, SESSION_DURATION_ATTRIBUTE_ID, minInterval, maxInterval); } public void readSessionEnergyChargedAttribute( - LongAttributeCallback callback) { + SessionEnergyChargedAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SESSION_ENERGY_CHARGED_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } }, SESSION_ENERGY_CHARGED_ATTRIBUTE_ID, true); } public void subscribeSessionEnergyChargedAttribute( - LongAttributeCallback callback, int minInterval, int maxInterval) { + SessionEnergyChargedAttributeCallback callback, int minInterval, int maxInterval) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SESSION_ENERGY_CHARGED_ATTRIBUTE_ID); subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } }, SESSION_ENERGY_CHARGED_ATTRIBUTE_ID, minInterval, maxInterval); } public void readSessionEnergyDischargedAttribute( - LongAttributeCallback callback) { + SessionEnergyDischargedAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SESSION_ENERGY_DISCHARGED_ATTRIBUTE_ID); readAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); callback.onSuccess(value); } }, SESSION_ENERGY_DISCHARGED_ATTRIBUTE_ID, true); } public void subscribeSessionEnergyDischargedAttribute( - LongAttributeCallback callback, int minInterval, int maxInterval) { + SessionEnergyDischargedAttributeCallback callback, int minInterval, int maxInterval) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, SESSION_ENERGY_DISCHARGED_ATTRIBUTE_ID); subscribeAttribute(new ReportCallbackImpl(callback, path) { @Override public void onSuccess(byte[] tlv) { - Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + @Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); } }, SESSION_ENERGY_DISCHARGED_ATTRIBUTE_ID, minInterval, maxInterval); } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java index 81b0180a39df4f..79d160371f9712 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java @@ -3759,7 +3759,7 @@ public String toString() { } } public static class EnergyEvseClusterFaultEvent { - public Long sessionID; + public @Nullable Long sessionID; public Integer state; public Integer faultStatePreviousState; public Integer faultStateCurrentState; @@ -3769,7 +3769,7 @@ public static class EnergyEvseClusterFaultEvent { private static final long FAULT_STATE_CURRENT_STATE_ID = 4L; public EnergyEvseClusterFaultEvent( - Long sessionID, + @Nullable Long sessionID, Integer state, Integer faultStatePreviousState, Integer faultStateCurrentState @@ -3782,7 +3782,7 @@ public EnergyEvseClusterFaultEvent( public StructType encodeTlv() { ArrayList values = new ArrayList<>(); - values.add(new StructElement(SESSION_I_D_ID, new UIntType(sessionID))); + values.add(new StructElement(SESSION_I_D_ID, sessionID != null ? new UIntType(sessionID) : new NullType())); values.add(new StructElement(STATE_ID, new UIntType(state))); values.add(new StructElement(FAULT_STATE_PREVIOUS_STATE_ID, new UIntType(faultStatePreviousState))); values.add(new StructElement(FAULT_STATE_CURRENT_STATE_ID, new UIntType(faultStateCurrentState))); @@ -3794,7 +3794,7 @@ public static EnergyEvseClusterFaultEvent decodeTlv(BaseTLVType tlvValue) { if (tlvValue == null || tlvValue.type() != TLVType.Struct) { return null; } - Long sessionID = null; + @Nullable Long sessionID = null; Integer state = null; Integer faultStatePreviousState = null; Integer faultStateCurrentState = null; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java index 0237b3fc989cd2..e7e40657b7915f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java @@ -7276,26 +7276,26 @@ public String toString() { } } public static class EnergyEvseClusterChargingTargetStruct { - public Integer targetTime; + public Integer targetTimeMinutesPastMidnight; public Optional targetSoC; public Optional addedEnergy; - private static final long TARGET_TIME_ID = 0L; + private static final long TARGET_TIME_MINUTES_PAST_MIDNIGHT_ID = 0L; private static final long TARGET_SO_C_ID = 1L; private static final long ADDED_ENERGY_ID = 2L; public EnergyEvseClusterChargingTargetStruct( - Integer targetTime, + Integer targetTimeMinutesPastMidnight, Optional targetSoC, Optional addedEnergy ) { - this.targetTime = targetTime; + this.targetTimeMinutesPastMidnight = targetTimeMinutesPastMidnight; this.targetSoC = targetSoC; this.addedEnergy = addedEnergy; } public StructType encodeTlv() { ArrayList values = new ArrayList<>(); - values.add(new StructElement(TARGET_TIME_ID, new UIntType(targetTime))); + values.add(new StructElement(TARGET_TIME_MINUTES_PAST_MIDNIGHT_ID, new UIntType(targetTimeMinutesPastMidnight))); values.add(new StructElement(TARGET_SO_C_ID, targetSoC.map((nonOptionaltargetSoC) -> new UIntType(nonOptionaltargetSoC)).orElse(new EmptyType()))); values.add(new StructElement(ADDED_ENERGY_ID, addedEnergy.map((nonOptionaladdedEnergy) -> new IntType(nonOptionaladdedEnergy)).orElse(new EmptyType()))); @@ -7306,14 +7306,14 @@ public static EnergyEvseClusterChargingTargetStruct decodeTlv(BaseTLVType tlvVal if (tlvValue == null || tlvValue.type() != TLVType.Struct) { return null; } - Integer targetTime = null; + Integer targetTimeMinutesPastMidnight = null; Optional targetSoC = Optional.empty(); Optional addedEnergy = Optional.empty(); for (StructElement element: ((StructType)tlvValue).value()) { - if (element.contextTagNum() == TARGET_TIME_ID) { + if (element.contextTagNum() == TARGET_TIME_MINUTES_PAST_MIDNIGHT_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { UIntType castingValue = element.value(UIntType.class); - targetTime = castingValue.value(Integer.class); + targetTimeMinutesPastMidnight = castingValue.value(Integer.class); } } else if (element.contextTagNum() == TARGET_SO_C_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -7328,7 +7328,7 @@ public static EnergyEvseClusterChargingTargetStruct decodeTlv(BaseTLVType tlvVal } } return new EnergyEvseClusterChargingTargetStruct( - targetTime, + targetTimeMinutesPastMidnight, targetSoC, addedEnergy ); @@ -7338,8 +7338,8 @@ public static EnergyEvseClusterChargingTargetStruct decodeTlv(BaseTLVType tlvVal public String toString() { StringBuilder output = new StringBuilder(); output.append("EnergyEvseClusterChargingTargetStruct {\n"); - output.append("\ttargetTime: "); - output.append(targetTime); + output.append("\ttargetTimeMinutesPastMidnight: "); + output.append(targetTimeMinutesPastMidnight); output.append("\n"); output.append("\ttargetSoC: "); output.append(targetSoC); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index b92600bc9890a4..91b7d28b9fe564 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -10747,6 +10747,69 @@ public void onError(Exception ex) { } } + public static class DelegatedEnergyEvseClusterSessionDurationAttributeCallback implements ChipClusters.EnergyEvseCluster.SessionDurationAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedEnergyEvseClusterSessionEnergyChargedAttributeCallback implements ChipClusters.EnergyEvseCluster.SessionEnergyChargedAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedEnergyEvseClusterSessionEnergyDischargedAttributeCallback implements ChipClusters.EnergyEvseCluster.SessionEnergyDischargedAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedEnergyEvseClusterGeneratedCommandListAttributeCallback implements ChipClusters.EnergyEvseCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index fecf9c31d761ee..ec96ce4c2bc8a7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -9542,10 +9542,10 @@ private static Map readEnergyEvseInteractionInfo() { InteractionInfo readEnergyEvseSessionDurationAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.EnergyEvseCluster) cluster).readSessionDurationAttribute( - (ChipClusters.LongAttributeCallback) callback + (ChipClusters.EnergyEvseCluster.SessionDurationAttributeCallback) callback ); }, - () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + () -> new ClusterInfoMapping.DelegatedEnergyEvseClusterSessionDurationAttributeCallback(), readEnergyEvseSessionDurationCommandParams ); result.put("readSessionDurationAttribute", readEnergyEvseSessionDurationAttributeInteractionInfo); @@ -9553,10 +9553,10 @@ private static Map readEnergyEvseInteractionInfo() { InteractionInfo readEnergyEvseSessionEnergyChargedAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.EnergyEvseCluster) cluster).readSessionEnergyChargedAttribute( - (ChipClusters.LongAttributeCallback) callback + (ChipClusters.EnergyEvseCluster.SessionEnergyChargedAttributeCallback) callback ); }, - () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + () -> new ClusterInfoMapping.DelegatedEnergyEvseClusterSessionEnergyChargedAttributeCallback(), readEnergyEvseSessionEnergyChargedCommandParams ); result.put("readSessionEnergyChargedAttribute", readEnergyEvseSessionEnergyChargedAttributeInteractionInfo); @@ -9564,10 +9564,10 @@ private static Map readEnergyEvseInteractionInfo() { InteractionInfo readEnergyEvseSessionEnergyDischargedAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.EnergyEvseCluster) cluster).readSessionEnergyDischargedAttribute( - (ChipClusters.LongAttributeCallback) callback + (ChipClusters.EnergyEvseCluster.SessionEnergyDischargedAttributeCallback) callback ); }, - () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + () -> new ClusterInfoMapping.DelegatedEnergyEvseClusterSessionEnergyDischargedAttributeCallback(), readEnergyEvseSessionEnergyDischargedCommandParams ); result.put("readSessionEnergyDischargedAttribute", readEnergyEvseSessionEnergyDischargedAttributeInteractionInfo); diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index 2b82c363aa442c..53ca88273b038d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -23,7 +23,7 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class EnergyEvseClusterFaultEvent( - val sessionID: ULong, + val sessionID: ULong?, val state: UInt, val faultStatePreviousState: UInt, val faultStateCurrentState: UInt @@ -40,7 +40,11 @@ class EnergyEvseClusterFaultEvent( fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { tlvWriter.apply { startStructure(tlvTag) - put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) + if (sessionID != null) { + put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) + } else { + putNull(ContextSpecificTag(TAG_SESSION_I_D)) + } put(ContextSpecificTag(TAG_STATE), state) put(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE), faultStatePreviousState) put(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE), faultStateCurrentState) @@ -56,7 +60,13 @@ class EnergyEvseClusterFaultEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) + val sessionID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val faultStatePreviousState = tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index f457f066ff27bc..9e859dbdf40e53 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -24,13 +24,13 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class EnergyEvseClusterChargingTargetStruct( - val targetTime: UInt, + val targetTimeMinutesPastMidnight: UInt, val targetSoC: Optional, val addedEnergy: Optional ) { override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetStruct {\n") - append("\ttargetTime : $targetTime\n") + append("\ttargetTimeMinutesPastMidnight : $targetTimeMinutesPastMidnight\n") append("\ttargetSoC : $targetSoC\n") append("\taddedEnergy : $addedEnergy\n") append("}\n") @@ -39,7 +39,7 @@ class EnergyEvseClusterChargingTargetStruct( fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { tlvWriter.apply { startStructure(tlvTag) - put(ContextSpecificTag(TAG_TARGET_TIME), targetTime) + put(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT), targetTimeMinutesPastMidnight) if (targetSoC.isPresent) { val opttargetSoC = targetSoC.get() put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) @@ -53,13 +53,14 @@ class EnergyEvseClusterChargingTargetStruct( } companion object { - private const val TAG_TARGET_TIME = 0 + private const val TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT = 0 private const val TAG_TARGET_SO_C = 1 private const val TAG_ADDED_ENERGY = 2 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTime = tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME)) + val targetTimeMinutesPastMidnight = + tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SO_C))) @@ -75,7 +76,11 @@ class EnergyEvseClusterChargingTargetStruct( tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct(targetTime, targetSoC, addedEnergy) + return EnergyEvseClusterChargingTargetStruct( + targetTimeMinutesPastMidnight, + targetSoC, + addedEnergy + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt index 93e1c213748fe1..615839a2191b26 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt @@ -66,6 +66,12 @@ class EnergyEvseCluster(private val controller: MatterController, private val en class SessionIDAttribute(val value: UInt?) + class SessionDurationAttribute(val value: UInt?) + + class SessionEnergyChargedAttribute(val value: Long?) + + class SessionEnergyDischargedAttribute(val value: Long?) + class GeneratedCommandListAttribute(val value: List) class AcceptedCommandListAttribute(val value: List) @@ -1230,7 +1236,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en return SessionIDAttribute(decodedValue) } - suspend fun readSessionDurationAttribute(): UInt { + suspend fun readSessionDurationAttribute(): SessionDurationAttribute { val ATTRIBUTE_ID: UInt = 65u val attributePath = @@ -1256,12 +1262,18 @@ class EnergyEvseCluster(private val controller: MatterController, private val en // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - return decodedValue + return SessionDurationAttribute(decodedValue) } - suspend fun readSessionEnergyChargedAttribute(): Long { + suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute { val ATTRIBUTE_ID: UInt = 66u val attributePath = @@ -1287,12 +1299,18 @@ class EnergyEvseCluster(private val controller: MatterController, private val en // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long = tlvReader.getLong(AnonymousTag) + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - return decodedValue + return SessionEnergyChargedAttribute(decodedValue) } - suspend fun readSessionEnergyDischargedAttribute(): Long? { + suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttribute { val ATTRIBUTE_ID: UInt = 67u val attributePath = @@ -1319,13 +1337,18 @@ class EnergyEvseCluster(private val controller: MatterController, private val en // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } } else { + tlvReader.getNull(AnonymousTag) null } - return decodedValue + return SessionEnergyDischargedAttribute(decodedValue) } suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index 03e5ca83816f70..2167c1fca408eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -23,7 +23,7 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class EnergyEvseClusterFaultEvent( - val sessionID: UInt, + val sessionID: UInt?, val state: UByte, val faultStatePreviousState: UByte, val faultStateCurrentState: UByte @@ -40,7 +40,11 @@ class EnergyEvseClusterFaultEvent( fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { tlvWriter.apply { startStructure(tlvTag) - put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) + if (sessionID != null) { + put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) + } else { + putNull(ContextSpecificTag(TAG_SESSION_I_D)) + } put(ContextSpecificTag(TAG_STATE), state) put(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE), faultStatePreviousState) put(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE), faultStateCurrentState) @@ -56,7 +60,13 @@ class EnergyEvseClusterFaultEvent( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) + val sessionID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val faultStatePreviousState = tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index 65c1b49f4af9f1..db61226e1adf55 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -24,13 +24,13 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class EnergyEvseClusterChargingTargetStruct( - val targetTime: UShort, + val targetTimeMinutesPastMidnight: UShort, val targetSoC: Optional, val addedEnergy: Optional ) { override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetStruct {\n") - append("\ttargetTime : $targetTime\n") + append("\ttargetTimeMinutesPastMidnight : $targetTimeMinutesPastMidnight\n") append("\ttargetSoC : $targetSoC\n") append("\taddedEnergy : $addedEnergy\n") append("}\n") @@ -39,7 +39,7 @@ class EnergyEvseClusterChargingTargetStruct( fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { tlvWriter.apply { startStructure(tlvTag) - put(ContextSpecificTag(TAG_TARGET_TIME), targetTime) + put(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT), targetTimeMinutesPastMidnight) if (targetSoC.isPresent) { val opttargetSoC = targetSoC.get() put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) @@ -53,13 +53,14 @@ class EnergyEvseClusterChargingTargetStruct( } companion object { - private const val TAG_TARGET_TIME = 0 + private const val TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT = 0 private const val TAG_TARGET_SO_C = 1 private const val TAG_ADDED_ENERGY = 2 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTime = tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME)) + val targetTimeMinutesPastMidnight = + tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TARGET_SO_C))) @@ -75,7 +76,11 @@ class EnergyEvseClusterChargingTargetStruct( tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct(targetTime, targetSoC, addedEnergy) + return EnergyEvseClusterChargingTargetStruct( + targetTimeMinutesPastMidnight, + targetSoC, + addedEnergy + ) } } } diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index e87c3ea5961c68..b1764fa2e9a1be 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -22723,11 +22723,18 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - jlong jnivalue = static_cast(cppValue); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - jnivalue, value); + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } return value; } case Attributes::SessionEnergyCharged::Id: { @@ -22739,11 +22746,18 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - jlong jnivalue = static_cast(cppValue); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - jnivalue, value); + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } return value; } case Attributes::SessionEnergyDischarged::Id: { @@ -22755,11 +22769,18 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - std::string valueClassName = "java/lang/Long"; - std::string valueCtorSignature = "(J)V"; - jlong jnivalue = static_cast(cppValue); - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - jnivalue, value); + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } return value; } case Attributes::GeneratedCommandList::Id: { diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 4dd1ffd1e2e2c1..6e3b2093ead51c 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -5248,11 +5248,18 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } jobject value_sessionID; - std::string value_sessionIDClassName = "java/lang/Long"; - std::string value_sessionIDCtorSignature = "(J)V"; - jlong jnivalue_sessionID = static_cast(cppValue.sessionID); - chip::JniReferences::GetInstance().CreateBoxedObject( - value_sessionIDClassName.c_str(), value_sessionIDCtorSignature.c_str(), jnivalue_sessionID, value_sessionID); + if (cppValue.sessionID.IsNull()) + { + value_sessionID = nullptr; + } + else + { + std::string value_sessionIDClassName = "java/lang/Long"; + std::string value_sessionIDCtorSignature = "(J)V"; + jlong jnivalue_sessionID = static_cast(cppValue.sessionID.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_sessionIDClassName.c_str(), value_sessionIDCtorSignature.c_str(), jnivalue_sessionID, value_sessionID); + } jobject value_state; std::string value_stateClassName = "java/lang/Integer"; diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp index 3b65b69a3a456a..2b5fa3ff8429ea 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp @@ -3959,13 +3959,14 @@ void CHIPEnergyEvseClusterGetTargetsResponseCallback::CallbackFn( { auto & entry_0 = iter_ChargingTargets_0.GetValue(); jobject newElement_0; - jobject newElement_0_targetTime; - std::string newElement_0_targetTimeClassName = "java/lang/Integer"; - std::string newElement_0_targetTimeCtorSignature = "(I)V"; - jint jninewElement_0_targetTime = static_cast(entry_0.targetTime); - chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_targetTimeClassName.c_str(), - newElement_0_targetTimeCtorSignature.c_str(), - jninewElement_0_targetTime, newElement_0_targetTime); + jobject newElement_0_targetTimeMinutesPastMidnight; + std::string newElement_0_targetTimeMinutesPastMidnightClassName = "java/lang/Integer"; + std::string newElement_0_targetTimeMinutesPastMidnightCtorSignature = "(I)V"; + jint jninewElement_0_targetTimeMinutesPastMidnight = static_cast(entry_0.targetTimeMinutesPastMidnight); + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_targetTimeMinutesPastMidnightClassName.c_str(), + newElement_0_targetTimeMinutesPastMidnightCtorSignature.c_str(), + jninewElement_0_targetTimeMinutesPastMidnight, + newElement_0_targetTimeMinutesPastMidnight); jobject newElement_0_targetSoC; if (!entry_0.targetSoC.HasValue()) { @@ -4016,8 +4017,8 @@ void CHIPEnergyEvseClusterGetTargetsResponseCallback::CallbackFn( return; } - newElement_0 = env->NewObject(chargingTargetStructStructClass_1, chargingTargetStructStructCtor_1, newElement_0_targetTime, - newElement_0_targetSoC, newElement_0_addedEnergy); + newElement_0 = env->NewObject(chargingTargetStructStructClass_1, chargingTargetStructStructCtor_1, + newElement_0_targetTimeMinutesPastMidnight, newElement_0_targetSoC, newElement_0_addedEnergy); chip::JniReferences::GetInstance().AddToList(ChargingTargets, newElement_0); } diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index 630984be29b0a7..e7d797ce9f0e92 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -33874,6 +33874,208 @@ void CHIPEnergyEvseSessionIDAttributeCallback::CallbackFn(void * context, const env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); } +CHIPEnergyEvseSessionDurationAttributeCallback::CHIPEnergyEvseSessionDurationAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPEnergyEvseSessionDurationAttributeCallback::~CHIPEnergyEvseSessionDurationAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPEnergyEvseSessionDurationAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Long"; + std::string javaValueCtorSignature = "(J)V"; + jlong jnijavaValue = static_cast(value.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + jnijavaValue, javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + +CHIPEnergyEvseSessionEnergyChargedAttributeCallback::CHIPEnergyEvseSessionEnergyChargedAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPEnergyEvseSessionEnergyChargedAttributeCallback::~CHIPEnergyEvseSessionEnergyChargedAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPEnergyEvseSessionEnergyChargedAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Long"; + std::string javaValueCtorSignature = "(J)V"; + jlong jnijavaValue = static_cast(value.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + jnijavaValue, javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + +CHIPEnergyEvseSessionEnergyDischargedAttributeCallback::CHIPEnergyEvseSessionEnergyDischargedAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPEnergyEvseSessionEnergyDischargedAttributeCallback::~CHIPEnergyEvseSessionEnergyDischargedAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPEnergyEvseSessionEnergyDischargedAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Long"; + std::string javaValueCtorSignature = "(J)V"; + jlong jnijavaValue = static_cast(value.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + jnijavaValue, javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + CHIPEnergyEvseGeneratedCommandListAttributeCallback::CHIPEnergyEvseGeneratedCommandListAttributeCallback(jobject javaCallback, bool keepAlive) : chip::Callback::Callback(CallbackFn, this), keepAlive(keepAlive) diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 735228c9725f71..5fd82a3382a339 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -23780,9 +23780,9 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="batteryCapacity", Tag=0x00000031, Type=typing.Union[None, Nullable, int]), ClusterObjectFieldDescriptor(Label="vehicleID", Tag=0x00000032, Type=typing.Union[None, Nullable, str]), ClusterObjectFieldDescriptor(Label="sessionID", Tag=0x00000040, Type=typing.Union[Nullable, uint]), - ClusterObjectFieldDescriptor(Label="sessionDuration", Tag=0x00000041, Type=uint), - ClusterObjectFieldDescriptor(Label="sessionEnergyCharged", Tag=0x00000042, Type=int), - ClusterObjectFieldDescriptor(Label="sessionEnergyDischarged", Tag=0x00000043, Type=typing.Optional[int]), + ClusterObjectFieldDescriptor(Label="sessionDuration", Tag=0x00000041, Type=typing.Union[Nullable, uint]), + ClusterObjectFieldDescriptor(Label="sessionEnergyCharged", Tag=0x00000042, Type=typing.Union[Nullable, int]), + ClusterObjectFieldDescriptor(Label="sessionEnergyDischarged", Tag=0x00000043, Type=typing.Union[None, Nullable, int]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -23813,9 +23813,9 @@ def descriptor(cls) -> ClusterObjectDescriptor: batteryCapacity: 'typing.Union[None, Nullable, int]' = None vehicleID: 'typing.Union[None, Nullable, str]' = None sessionID: 'typing.Union[Nullable, uint]' = None - sessionDuration: 'uint' = None - sessionEnergyCharged: 'int' = None - sessionEnergyDischarged: 'typing.Optional[int]' = None + sessionDuration: 'typing.Union[Nullable, uint]' = None + sessionEnergyCharged: 'typing.Union[Nullable, int]' = None + sessionEnergyDischarged: 'typing.Union[None, Nullable, int]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -23908,12 +23908,12 @@ class ChargingTargetStruct(ClusterObject): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="targetTime", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="targetTimeMinutesPastMidnight", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="targetSoC", Tag=1, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="addedEnergy", Tag=2, Type=typing.Optional[int]), ]) - targetTime: 'uint' = 0 + targetTimeMinutesPastMidnight: 'uint' = 0 targetSoC: 'typing.Optional[uint]' = None addedEnergy: 'typing.Optional[int]' = None @@ -24440,9 +24440,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) + return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, uint]) - value: 'uint' = 0 + value: 'typing.Union[Nullable, uint]' = NullValue @dataclass class SessionEnergyCharged(ClusterAttributeDescriptor): @@ -24456,9 +24456,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=int) + return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, int]) - value: 'int' = 0 + value: 'typing.Union[Nullable, int]' = NullValue @dataclass class SessionEnergyDischarged(ClusterAttributeDescriptor): @@ -24472,9 +24472,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[int]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, int]) - value: 'typing.Optional[int]' = None + value: 'typing.Union[None, Nullable, int]' = None @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @@ -24681,13 +24681,13 @@ def event_id(cls) -> int: def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="sessionID", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="sessionID", Tag=0, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="state", Tag=1, Type=EnergyEvse.Enums.StateEnum), ClusterObjectFieldDescriptor(Label="faultStatePreviousState", Tag=2, Type=EnergyEvse.Enums.FaultStateEnum), ClusterObjectFieldDescriptor(Label="faultStateCurrentState", Tag=4, Type=EnergyEvse.Enums.FaultStateEnum), ]) - sessionID: 'uint' = 0 + sessionID: 'typing.Union[Nullable, uint]' = NullValue state: 'EnergyEvse.Enums.StateEnum' = 0 faultStatePreviousState: 'EnergyEvse.Enums.FaultStateEnum' = 0 faultStateCurrentState: 'EnergyEvse.Enums.FaultStateEnum' = 0 diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 2deb87873533aa..25d41e9c8bf966 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -8723,8 +8723,12 @@ static id _Nullable DecodeAttributeValueForEnergyEVSECluster(AttributeId aAttrib if (*aError != CHIP_NO_ERROR) { return nil; } - NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedInt:cppValue]; + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithUnsignedInt:cppValue.Value()]; + } return value; } case Attributes::SessionEnergyCharged::Id: { @@ -8734,8 +8738,12 @@ static id _Nullable DecodeAttributeValueForEnergyEVSECluster(AttributeId aAttrib if (*aError != CHIP_NO_ERROR) { return nil; } - NSNumber * _Nonnull value; - value = [NSNumber numberWithLongLong:cppValue]; + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } return value; } case Attributes::SessionEnergyDischarged::Id: { @@ -8745,8 +8753,12 @@ static id _Nullable DecodeAttributeValueForEnergyEVSECluster(AttributeId aAttrib if (*aError != CHIP_NO_ERROR) { return nil; } - NSNumber * _Nonnull value; - value = [NSNumber numberWithLongLong:cppValue]; + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithLongLong:cppValue.Value()]; + } return value; } default: { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index f9cfc8e297a801..5d47571ec5ad3e 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -16910,7 +16910,7 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::EnergyEv auto & entry_0 = iter_0.GetValue(); MTREnergyEVSEClusterChargingTargetStruct * newElement_0; newElement_0 = [MTREnergyEVSEClusterChargingTargetStruct new]; - newElement_0.targetTime = [NSNumber numberWithUnsignedShort:entry_0.targetTime]; + newElement_0.targetTimeMinutesPastMidnight = [NSNumber numberWithUnsignedShort:entry_0.targetTimeMinutesPastMidnight]; if (entry_0.targetSoC.HasValue()) { newElement_0.targetSoC = [NSNumber numberWithUnsignedChar:entry_0.targetSoC.Value()]; } else { @@ -17326,7 +17326,7 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader return CHIP_ERROR_INVALID_ARGUMENT; } auto element_0 = (MTREnergyEVSEClusterChargingTargetStruct *) self.chargingTargets[i_0]; - listHolder_0->mList[i_0].targetTime = element_0.targetTime.unsignedShortValue; + listHolder_0->mList[i_0].targetTimeMinutesPastMidnight = element_0.targetTimeMinutesPastMidnight.unsignedShortValue; if (element_0.targetSoC != nil) { auto & definedValue_2 = listHolder_0->mList[i_0].targetSoC.Emplace(); definedValue_2 = element_0.targetSoC.unsignedCharValue; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index c9a38080b463dc..fdffaae3ca3761 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -2978,8 +2978,12 @@ static id _Nullable DecodeEventPayloadForEnergyEVSECluster(EventId aEventId, TLV __auto_type * value = [MTREnergyEVSEClusterFaultEvent new]; do { - NSNumber * _Nonnull memberValue; - memberValue = [NSNumber numberWithUnsignedInt:cppValue.sessionID]; + NSNumber * _Nullable memberValue; + if (cppValue.sessionID.IsNull()) { + memberValue = nil; + } else { + memberValue = [NSNumber numberWithUnsignedInt:cppValue.sessionID.Value()]; + } value.sessionID = memberValue; } while (0); do { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index 6242c7e9460229..f76506226b4701 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1275,7 +1275,7 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTREnergyEVSEClusterChargingTargetStruct : NSObject -@property (nonatomic, copy) NSNumber * _Nonnull targetTime MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull targetTimeMinutesPastMidnight MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable targetSoC MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable addedEnergy MTR_PROVISIONALLY_AVAILABLE; @end @@ -1311,7 +1311,7 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTREnergyEVSEClusterFaultEvent : NSObject -@property (nonatomic, copy) NSNumber * _Nonnull sessionID MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable sessionID MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull state MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull faultStatePreviousState MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull faultStateCurrentState MTR_PROVISIONALLY_AVAILABLE; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 06be97e69ee61b..4c08c7228fd870 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -5203,7 +5203,7 @@ - (instancetype)init { if (self = [super init]) { - _targetTime = @(0); + _targetTimeMinutesPastMidnight = @(0); _targetSoC = nil; @@ -5216,7 +5216,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone { auto other = [[MTREnergyEVSEClusterChargingTargetStruct alloc] init]; - other.targetTime = self.targetTime; + other.targetTimeMinutesPastMidnight = self.targetTimeMinutesPastMidnight; other.targetSoC = self.targetSoC; other.addedEnergy = self.addedEnergy; @@ -5225,7 +5225,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: targetTime:%@; targetSoC:%@; addedEnergy:%@; >", NSStringFromClass([self class]), _targetTime, _targetSoC, _addedEnergy]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: targetTimeMinutesPastMidnight:%@; targetSoC:%@; addedEnergy:%@; >", NSStringFromClass([self class]), _targetTimeMinutesPastMidnight, _targetSoC, _addedEnergy]; return descriptionString; } @@ -5371,7 +5371,7 @@ - (instancetype)init { if (self = [super init]) { - _sessionID = @(0); + _sessionID = nil; _state = @(0); diff --git a/zzz_generated/app-common/app-common/zap-generated/attribute-type.h b/zzz_generated/app-common/app-common/zap-generated/attribute-type.h index c14a0614f6a1c4..6f4c3bc90208e2 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-type.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-type.h @@ -73,6 +73,10 @@ enum ZCL_SYSTIME_MS_ATTRIBUTE_TYPE = 0xD1, // System Time Milliseconds ZCL_ELAPSED_S_ATTRIBUTE_TYPE = 0xD2, // Elapsed Time Seconds ZCL_TEMPERATURE_ATTRIBUTE_TYPE = 0xD8, // Temperature + ZCL_POWER_MW_ATTRIBUTE_TYPE = 0xD9, // Power milliwatts + ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE = 0xDA, // Amperage milliamps + ZCL_VOLTAGE_MV_ATTRIBUTE_TYPE = 0xDB, // Voltage millivolts + ZCL_ENERGY_MWH_ATTRIBUTE_TYPE = 0xDC, // Energy milliwatt-hours ZCL_TOD_ATTRIBUTE_TYPE = 0xE0, // Time of day ZCL_DATE_ATTRIBUTE_TYPE = 0xE1, // Date ZCL_EPOCH_US_ATTRIBUTE_TYPE = 0xE3, // Epoch Microseconds diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index c418c95d1b55ea..5d63549606dbf7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -10957,7 +10957,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE); } } // namespace CircuitCapacity @@ -10988,7 +10988,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE); } } // namespace MinimumChargeCurrent @@ -11019,7 +11019,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE); } } // namespace MaximumChargeCurrent @@ -11050,7 +11050,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE); } } // namespace MaximumDischargeCurrent @@ -11081,7 +11081,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE); } } // namespace UserMaximumChargeCurrent @@ -11314,7 +11314,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); } EmberAfStatus SetNull(chip::EndpointId endpoint) @@ -11323,7 +11323,7 @@ EmberAfStatus SetNull(chip::EndpointId endpoint) Traits::StorageType value; Traits::SetNull(value); uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); } EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) @@ -11526,7 +11526,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); } EmberAfStatus SetNull(chip::EndpointId endpoint) @@ -11535,7 +11535,7 @@ EmberAfStatus SetNull(chip::EndpointId endpoint) Traits::StorageType value; Traits::SetNull(value); uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); } EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) @@ -11654,24 +11654,27 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl namespace SessionDuration { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EnergyEvse::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } @@ -11681,66 +11684,129 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value) return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ELAPSED_S_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ELAPSED_S_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace SessionDuration namespace SessionEnergyCharged { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EnergyEvse::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); +} + +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); } } // namespace SessionEnergyCharged namespace SessionEnergyDischarged { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::EnergyEvse::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, int64_t value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_INT64S_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); +} + +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::EnergyEvse::Id, Id, writable, ZCL_ENERGY_MWH_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); } } // namespace SessionEnergyDischarged diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 70f24570d9770e..71cae4fffd6e43 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -2107,27 +2107,27 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl } // namespace DischargingEnabledUntil namespace CircuitCapacity { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // amperage_ma EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); } // namespace CircuitCapacity namespace MinimumChargeCurrent { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // amperage_ma EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); } // namespace MinimumChargeCurrent namespace MaximumChargeCurrent { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // amperage_ma EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); } // namespace MaximumChargeCurrent namespace MaximumDischargeCurrent { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // amperage_ma EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); } // namespace MaximumDischargeCurrent namespace UserMaximumChargeCurrent { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // amperage_ma EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); } // namespace UserMaximumChargeCurrent @@ -2161,7 +2161,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl } // namespace NextChargeTargetTime namespace NextChargeRequiredEnergy { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // energy_mwh EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); EmberAfStatus SetNull(chip::EndpointId endpoint); EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); @@ -2189,7 +2189,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl } // namespace StateOfCharge namespace BatteryCapacity { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // energy_mwh EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); EmberAfStatus SetNull(chip::EndpointId endpoint); EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); @@ -2210,18 +2210,24 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl } // namespace SessionID namespace SessionDuration { -EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // elapsed_s +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // elapsed_s EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); } // namespace SessionDuration namespace SessionEnergyCharged { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // energy_mwh EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); } // namespace SessionEnergyCharged namespace SessionEnergyDischarged { -EmberAfStatus Get(chip::EndpointId endpoint, int64_t * value); // int64s +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // energy_mwh EmberAfStatus Set(chip::EndpointId endpoint, int64_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); } // namespace SessionEnergyDischarged namespace FeatureMap { 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 4869634c35461f..99196eceb6effc 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 @@ -15763,7 +15763,7 @@ namespace ChargingTargetStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; - encoder.Encode(to_underlying(Fields::kTargetTime), targetTime); + encoder.Encode(to_underlying(Fields::kTargetTimeMinutesPastMidnight), targetTimeMinutesPastMidnight); encoder.Encode(to_underlying(Fields::kTargetSoC), targetSoC); encoder.Encode(to_underlying(Fields::kAddedEnergy), addedEnergy); return encoder.Finalize(); @@ -15783,9 +15783,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::kTargetTime)) + if (__context_tag == to_underlying(Fields::kTargetTimeMinutesPastMidnight)) { - err = DataModel::Decode(reader, targetTime); + err = DataModel::Decode(reader, targetTimeMinutesPastMidnight); } else if (__context_tag == to_underlying(Fields::kTargetSoC)) { 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 9438ed24a7cd5f..7c90c8a9d5a3e1 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 @@ -21865,15 +21865,15 @@ namespace Structs { namespace ChargingTargetStruct { enum class Fields : uint8_t { - kTargetTime = 0, - kTargetSoC = 1, - kAddedEnergy = 2, + kTargetTimeMinutesPastMidnight = 0, + kTargetSoC = 1, + kAddedEnergy = 2, }; struct Type { public: - uint16_t targetTime = static_cast(0); + uint16_t targetTimeMinutesPastMidnight = static_cast(0); Optional targetSoC; Optional addedEnergy; @@ -22466,9 +22466,9 @@ struct TypeInfo namespace SessionDuration { struct TypeInfo { - using Type = uint32_t; - using DecodableType = uint32_t; - using DecodableArgType = uint32_t; + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; static constexpr ClusterId GetClusterId() { return Clusters::EnergyEvse::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::SessionDuration::Id; } @@ -22478,9 +22478,9 @@ struct TypeInfo namespace SessionEnergyCharged { struct TypeInfo { - using Type = int64_t; - using DecodableType = int64_t; - using DecodableArgType = int64_t; + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; static constexpr ClusterId GetClusterId() { return Clusters::EnergyEvse::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::SessionEnergyCharged::Id; } @@ -22490,9 +22490,9 @@ struct TypeInfo namespace SessionEnergyDischarged { struct TypeInfo { - using Type = int64_t; - using DecodableType = int64_t; - using DecodableArgType = int64_t; + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; static constexpr ClusterId GetClusterId() { return Clusters::EnergyEvse::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::SessionEnergyDischarged::Id; } @@ -22568,9 +22568,9 @@ struct TypeInfo Attributes::BatteryCapacity::TypeInfo::DecodableType batteryCapacity; Attributes::VehicleID::TypeInfo::DecodableType vehicleID; Attributes::SessionID::TypeInfo::DecodableType sessionID; - Attributes::SessionDuration::TypeInfo::DecodableType sessionDuration = static_cast(0); - Attributes::SessionEnergyCharged::TypeInfo::DecodableType sessionEnergyCharged = static_cast(0); - Attributes::SessionEnergyDischarged::TypeInfo::DecodableType sessionEnergyDischarged = static_cast(0); + Attributes::SessionDuration::TypeInfo::DecodableType sessionDuration; + Attributes::SessionEnergyCharged::TypeInfo::DecodableType sessionEnergyCharged; + Attributes::SessionEnergyDischarged::TypeInfo::DecodableType sessionEnergyDischarged; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; @@ -22759,7 +22759,7 @@ struct Type static constexpr ClusterId GetClusterId() { return Clusters::EnergyEvse::Id; } static constexpr bool kIsFabricScoped = false; - uint32_t sessionID = static_cast(0); + DataModel::Nullable sessionID; StateEnum state = static_cast(0); FaultStateEnum faultStatePreviousState = static_cast(0); FaultStateEnum faultStateCurrentState = static_cast(0); @@ -22774,7 +22774,7 @@ struct DecodableType static constexpr EventId GetEventId() { return Events::Fault::Id; } static constexpr ClusterId GetClusterId() { return Clusters::EnergyEvse::Id; } - uint32_t sessionID = static_cast(0); + DataModel::Nullable sessionID; StateEnum state = static_cast(0); FaultStateEnum faultStatePreviousState = static_cast(0); FaultStateEnum faultStateCurrentState = static_cast(0); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index f1020496d9781d..71dfbb1e03a9b8 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -7238,8 +7238,8 @@ class EnergyEvseEnableCharging : public ClusterCommand EnergyEvseEnableCharging(CredentialIssuerCommands * credsIssuerConfig) : ClusterCommand("enable-charging", credsIssuerConfig) { AddArgument("ChargingEnabledUntil", 0, UINT32_MAX, &mRequest.chargingEnabledUntil); - AddArgument("MinimumChargeCurrent", INT64_MIN, INT64_MAX, &mRequest.minimumChargeCurrent); - AddArgument("MaximumChargeCurrent", INT64_MIN, INT64_MAX, &mRequest.maximumChargeCurrent); + AddArgument("MinimumChargeCurrent", 0, UINT64_MAX, &mRequest.minimumChargeCurrent); + AddArgument("MaximumChargeCurrent", 0, UINT64_MAX, &mRequest.maximumChargeCurrent); ClusterCommand::AddArguments(); } @@ -7278,7 +7278,7 @@ class EnergyEvseEnableDischarging : public ClusterCommand ClusterCommand("enable-discharging", credsIssuerConfig) { AddArgument("DischargingEnabledUntil", 0, UINT32_MAX, &mRequest.dischargingEnabledUntil); - AddArgument("MaximumDischargeCurrent", INT64_MIN, INT64_MAX, &mRequest.maximumDischargeCurrent); + AddArgument("MaximumDischargeCurrent", 0, UINT64_MAX, &mRequest.maximumDischargeCurrent); ClusterCommand::AddArguments(); } @@ -19708,18 +19708,16 @@ void registerClusterEnergyEvse(Commands & commands, CredentialIssuerCommands * c make_unique>>(Id, "discharging-enabled-until", 0, UINT32_MAX, Attributes::DischargingEnabledUntil::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "circuit-capacity", INT64_MIN, INT64_MAX, Attributes::CircuitCapacity::Id, + make_unique>(Id, "circuit-capacity", 0, UINT64_MAX, Attributes::CircuitCapacity::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "minimum-charge-current", INT64_MIN, INT64_MAX, - Attributes::MinimumChargeCurrent::Id, WriteCommandType::kForceWrite, - credsIssuerConfig), // - make_unique>(Id, "maximum-charge-current", INT64_MIN, INT64_MAX, - Attributes::MaximumChargeCurrent::Id, WriteCommandType::kForceWrite, - credsIssuerConfig), // - make_unique>(Id, "maximum-discharge-current", INT64_MIN, INT64_MAX, + make_unique>(Id, "minimum-charge-current", 0, UINT64_MAX, Attributes::MinimumChargeCurrent::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "maximum-charge-current", 0, UINT64_MAX, Attributes::MaximumChargeCurrent::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "maximum-discharge-current", 0, UINT64_MAX, Attributes::MaximumDischargeCurrent::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "user-maximum-charge-current", INT64_MIN, INT64_MAX, + make_unique>(Id, "user-maximum-charge-current", 0, UINT64_MAX, Attributes::UserMaximumChargeCurrent::Id, WriteCommandType::kWrite, credsIssuerConfig), // make_unique>(Id, "randomization-delay-window", 0, UINT32_MAX, @@ -19735,8 +19733,8 @@ void registerClusterEnergyEvse(Commands & commands, CredentialIssuerCommands * c make_unique>>(Id, "next-charge-target-time", 0, UINT32_MAX, Attributes::NextChargeTargetTime::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>>(Id, "next-charge-required-energy", INT64_MIN, - INT64_MAX, Attributes::NextChargeRequiredEnergy::Id, + make_unique>>(Id, "next-charge-required-energy", 0, UINT64_MAX, + Attributes::NextChargeRequiredEnergy::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "next-charge-target-so-c", 0, UINT8_MAX, Attributes::NextChargeTargetSoC::Id, WriteCommandType::kForceWrite, @@ -19747,21 +19745,22 @@ void registerClusterEnergyEvse(Commands & commands, CredentialIssuerCommands * c make_unique>>( Id, "state-of-charge", 0, UINT8_MAX, Attributes::StateOfCharge::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>>(Id, "battery-capacity", INT64_MIN, INT64_MAX, + make_unique>>(Id, "battery-capacity", 0, UINT64_MAX, Attributes::BatteryCapacity::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "vehicle-id", Attributes::VehicleID::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "session-id", 0, UINT32_MAX, Attributes::SessionID::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "session-duration", 0, UINT32_MAX, Attributes::SessionDuration::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "session-energy-charged", INT64_MIN, INT64_MAX, - Attributes::SessionEnergyCharged::Id, WriteCommandType::kForceWrite, - credsIssuerConfig), // - make_unique>(Id, "session-energy-discharged", INT64_MIN, INT64_MAX, - Attributes::SessionEnergyDischarged::Id, WriteCommandType::kForceWrite, - credsIssuerConfig), // + make_unique>>(Id, "session-duration", 0, UINT32_MAX, + Attributes::SessionDuration::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "session-energy-charged", 0, UINT64_MAX, + Attributes::SessionEnergyCharged::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>(Id, "session-energy-discharged", 0, UINT64_MAX, + Attributes::SessionEnergyDischarged::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 7aeb538c962c95..155f91f1db84c9 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -3215,13 +3215,15 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ChargingTargetStruct.targetTime", "targetTime", value.isMember("targetTime"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ChargingTargetStruct.targetTimeMinutesPastMidnight", + "targetTimeMinutesPastMidnight", + value.isMember("targetTimeMinutesPastMidnight"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "targetTime"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.targetTime, value["targetTime"])); - valueCopy.removeMember("targetTime"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "targetTimeMinutesPastMidnight"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.targetTimeMinutesPastMidnight, + value["targetTimeMinutesPastMidnight"])); + valueCopy.removeMember("targetTimeMinutesPastMidnight"); if (value.isMember("targetSoC")) { @@ -3242,7 +3244,7 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, void ComplexArgumentParser::Finalize(chip::app::Clusters::EnergyEvse::Structs::ChargingTargetStruct::Type & request) { - ComplexArgumentParser::Finalize(request.targetTime); + ComplexArgumentParser::Finalize(request.targetTimeMinutesPastMidnight); ComplexArgumentParser::Finalize(request.targetSoC); ComplexArgumentParser::Finalize(request.addedEnergy); } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 913a28be7583fc..6a56a914177981 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -2862,10 +2862,10 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("TargetTime", indent + 1, value.targetTime); + CHIP_ERROR err = LogValue("TargetTimeMinutesPastMidnight", indent + 1, value.targetTimeMinutesPastMidnight); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'TargetTime'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'TargetTimeMinutesPastMidnight'"); return err; } } @@ -12031,17 +12031,17 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("SessionID", 1, value); } case EnergyEvse::Attributes::SessionDuration::Id: { - uint32_t value; + chip::app::DataModel::Nullable value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("SessionDuration", 1, value); } case EnergyEvse::Attributes::SessionEnergyCharged::Id: { - int64_t value; + chip::app::DataModel::Nullable value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("SessionEnergyCharged", 1, value); } case EnergyEvse::Attributes::SessionEnergyDischarged::Id: { - int64_t value; + chip::app::DataModel::Nullable value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("SessionEnergyDischarged", 1, value); } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 1a33c71a4eb1b2..0286c8a22e36f7 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -80320,10 +80320,10 @@ class EnergyEvseEnableCharging : public ClusterCommand { AddArgument("ChargingEnabledUntil", 0, UINT32_MAX, &mRequest.chargingEnabledUntil); #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL - AddArgument("MinimumChargeCurrent", INT64_MIN, INT64_MAX, &mRequest.minimumChargeCurrent); + AddArgument("MinimumChargeCurrent", 0, UINT64_MAX, &mRequest.minimumChargeCurrent); #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL - AddArgument("MaximumChargeCurrent", INT64_MIN, INT64_MAX, &mRequest.maximumChargeCurrent); + AddArgument("MaximumChargeCurrent", 0, UINT64_MAX, &mRequest.maximumChargeCurrent); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -80389,7 +80389,7 @@ class EnergyEvseEnableDischarging : public ClusterCommand { AddArgument("DischargingEnabledUntil", 0, UINT32_MAX, &mRequest.dischargingEnabledUntil); #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL - AddArgument("MaximumDischargeCurrent", INT64_MIN, INT64_MAX, &mRequest.maximumDischargeCurrent); + AddArgument("MaximumDischargeCurrent", 0, UINT64_MAX, &mRequest.maximumDischargeCurrent); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -80524,7 +80524,7 @@ class EnergyEvseSetTargets : public ClusterCommand { for (auto & entry_0 : mRequest.chargingTargets) { MTREnergyEVSEClusterChargingTargetStruct * newElement_0; newElement_0 = [MTREnergyEVSEClusterChargingTargetStruct new]; - newElement_0.targetTime = [NSNumber numberWithUnsignedShort:entry_0.targetTime]; + newElement_0.targetTimeMinutesPastMidnight = [NSNumber numberWithUnsignedShort:entry_0.targetTimeMinutesPastMidnight]; if (entry_0.targetSoC.HasValue()) { newElement_0.targetSoC = [NSNumber numberWithUnsignedChar:entry_0.targetSoC.Value()]; } else { @@ -81481,7 +81481,7 @@ class WriteEnergyEvseUserMaximumChargeCurrent : public WriteAttribute { : WriteAttribute("user-maximum-charge-current") { AddArgument("attr-name", "user-maximum-charge-current"); - AddArgument("attr-value", INT64_MIN, INT64_MAX, &mValue); + AddArgument("attr-value", 0, UINT64_MAX, &mValue); WriteAttribute::AddArguments(); }