From 571e92426722523c5b98743ecabe04a44b421a15 Mon Sep 17 00:00:00 2001 From: Nivi Sarkar <55898241+nivi-apple@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:03:36 -0700 Subject: [PATCH] =?UTF-8?q?Update=20the=20preset=20handle=20field=20in=20t?= =?UTF-8?q?he=20SetActivePresetRequest=20c=E2=80=A6=20(#35105)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update the preset handle field in the SetActivePresetRequestRequest command to be nullable - Update the deleagte API for getting the active preset handle to return a nullable handle * Return error if CopySpanToMutableSpan fails * Restyled by clang-format * Apply suggestions from code review Co-authored-by: Boris Zbarsky --------- Co-authored-by: Restyled.io Co-authored-by: Boris Zbarsky --- .../air-purifier-app.matter | 2 +- .../all-clusters-app.matter | 2 +- .../all-clusters-minimal-app.matter | 2 +- ...umiditysensor_thermostat_56de3d5f45.matter | 2 +- ...tnode_heatingcoolingunit_ncdGai1E5a.matter | 2 +- ...tnode_roomairconditioner_9cf3607804.matter | 2 +- .../rootnode_thermostat_bm3fb8dhYi.matter | 2 +- .../placeholder/linux/apps/app1/config.matter | 4 +-- .../placeholder/linux/apps/app2/config.matter | 4 +-- .../linux/include/thermostat-delegate-impl.h | 2 +- .../linux/thermostat-delegate-impl.cpp | 14 +++++++++-- .../nxp/zap/thermostat_matter_thread.matter | 2 +- .../nxp/zap/thermostat_matter_wifi.matter | 2 +- .../qpg/zap/thermostaticRadiatorValve.matter | 2 +- .../thermostat-common/thermostat.matter | 2 +- .../thermostat-server/thermostat-delegate.h | 7 +++--- .../thermostat-server/thermostat-server.cpp | 25 ++++++++----------- .../data-model/chip/thermostat-cluster.xml | 2 +- .../data_model/controller-clusters.matter | 2 +- .../chip/devicecontroller/ChipClusters.java | 6 ++--- .../cluster/clusters/ThermostatCluster.kt | 4 +-- .../python/chip/clusters/Objects.py | 4 +-- .../zap-generated/MTRCommandPayloadsObjc.h | 2 +- .../zap-generated/MTRCommandPayloadsObjc.mm | 9 +++++-- .../zap-generated/cluster-objects.h | 4 +-- .../zap-generated/cluster/Commands.h | 6 ++++- 26 files changed, 65 insertions(+), 52 deletions(-) diff --git a/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter b/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter index cb1c102b239f3e..c35b8b62e24ee6 100644 --- a/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter +++ b/examples/air-purifier-app/air-purifier-common/air-purifier-app.matter @@ -1856,7 +1856,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index c18c6164c5c717..4180b1eef78e26 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -5696,7 +5696,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 16f170c1379591..363da41015d0b0 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -4130,7 +4130,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter index ed130f29318062..d47b3a90922d57 100644 --- a/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter +++ b/examples/chef/devices/rootnode_airpurifier_airqualitysensor_temperaturesensor_humiditysensor_thermostat_56de3d5f45.matter @@ -1779,7 +1779,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index ec62d4504f8601..84b5d949b6eeba 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -2136,7 +2136,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter index 95e0ba20d4adcb..20b7d6b80d35f5 100644 --- a/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter +++ b/examples/chef/devices/rootnode_roomairconditioner_9cf3607804.matter @@ -1719,7 +1719,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 6c27235c7d3ade..ae6441c2eaebea 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -1939,7 +1939,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 8befb87daa5f9a..33521a7a93fa75 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -5414,7 +5414,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -5769,7 +5769,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 6cfcc1ab7ea6cf..86d20b24a4f629 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -5371,7 +5371,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { @@ -5726,7 +5726,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/thermostat/linux/include/thermostat-delegate-impl.h b/examples/thermostat/linux/include/thermostat-delegate-impl.h index 8252f2274f9d79..6bf9d02cea462f 100644 --- a/examples/thermostat/linux/include/thermostat-delegate-impl.h +++ b/examples/thermostat/linux/include/thermostat-delegate-impl.h @@ -54,7 +54,7 @@ class ThermostatDelegate : public Delegate CHIP_ERROR GetPresetAtIndex(size_t index, PresetStructWithOwnedMembers & preset) override; - CHIP_ERROR GetActivePresetHandle(MutableByteSpan & activePresetHandle) override; + CHIP_ERROR GetActivePresetHandle(DataModel::Nullable & activePresetHandle) override; CHIP_ERROR SetActivePresetHandle(const DataModel::Nullable & newActivePresetHandle) override; diff --git a/examples/thermostat/linux/thermostat-delegate-impl.cpp b/examples/thermostat/linux/thermostat-delegate-impl.cpp index c39a757a8b0644..b931db20b7c4f7 100644 --- a/examples/thermostat/linux/thermostat-delegate-impl.cpp +++ b/examples/thermostat/linux/thermostat-delegate-impl.cpp @@ -117,9 +117,19 @@ CHIP_ERROR ThermostatDelegate::GetPresetAtIndex(size_t index, PresetStructWithOw return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; } -CHIP_ERROR ThermostatDelegate::GetActivePresetHandle(MutableByteSpan & activePresetHandle) +CHIP_ERROR ThermostatDelegate::GetActivePresetHandle(DataModel::Nullable & activePresetHandle) { - return CopySpanToMutableSpan(ByteSpan(mActivePresetHandleData, mActivePresetHandleDataSize), activePresetHandle); + if (mActivePresetHandleDataSize != 0) + { + ReturnErrorOnFailure( + CopySpanToMutableSpan(ByteSpan(mActivePresetHandleData, mActivePresetHandleDataSize), activePresetHandle.Value())); + activePresetHandle.Value().reduce_size(mActivePresetHandleDataSize); + } + else + { + activePresetHandle.SetNull(); + } + return CHIP_NO_ERROR; } CHIP_ERROR ThermostatDelegate::SetActivePresetHandle(const DataModel::Nullable & newActivePresetHandle) diff --git a/examples/thermostat/nxp/zap/thermostat_matter_thread.matter b/examples/thermostat/nxp/zap/thermostat_matter_thread.matter index 001e1b43ace09d..cbe6a6280d8ec4 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_thread.matter +++ b/examples/thermostat/nxp/zap/thermostat_matter_thread.matter @@ -2530,7 +2530,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter b/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter index 066afc85509947..cd9ddc362e36ce 100644 --- a/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter +++ b/examples/thermostat/nxp/zap/thermostat_matter_wifi.matter @@ -2441,7 +2441,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter b/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter index 31e5775d88148f..548db02c520b9a 100644 --- a/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter +++ b/examples/thermostat/qpg/zap/thermostaticRadiatorValve.matter @@ -2138,7 +2138,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index c53651c537894e..a66c2dfdad68ba 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -2318,7 +2318,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/src/app/clusters/thermostat-server/thermostat-delegate.h b/src/app/clusters/thermostat-server/thermostat-delegate.h index c8c21d898af167..0f89f69468099b 100644 --- a/src/app/clusters/thermostat-server/thermostat-delegate.h +++ b/src/app/clusters/thermostat-server/thermostat-delegate.h @@ -78,11 +78,10 @@ class Delegate /** * @brief Get the ActivePresetHandle attribute value. * - * @param[out] activePresetHandle The MutableByteSpan to copy the active preset handle into. On success, - * the callee must update the length to the length of the copied data. If the value of - * the attribute is null, the callee must set the MutableByteSpan to empty. + * @param[out] activePresetHandle The nullable MutableByteSpan to copy the active preset handle into. On success, + * the size of the activePresetHandle is updated to the length of the copied data. */ - virtual CHIP_ERROR GetActivePresetHandle(MutableByteSpan & activePresetHandle) = 0; + virtual CHIP_ERROR GetActivePresetHandle(DataModel::Nullable & activePresetHandle) = 0; /** * @brief Set the ActivePresetHandle attribute value. diff --git a/src/app/clusters/thermostat-server/thermostat-server.cpp b/src/app/clusters/thermostat-server/thermostat-server.cpp index 91c045c5ff540e..8fe70211eeda1a 100644 --- a/src/app/clusters/thermostat-server/thermostat-server.cpp +++ b/src/app/clusters/thermostat-server/thermostat-server.cpp @@ -761,19 +761,13 @@ CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, A VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Delegate is null")); uint8_t buffer[kPresetHandleSize]; - MutableByteSpan activePresetHandle(buffer); + MutableByteSpan activePresetHandleSpan(buffer); + auto activePresetHandle = DataModel::MakeNullable(activePresetHandleSpan); CHIP_ERROR err = delegate->GetActivePresetHandle(activePresetHandle); ReturnErrorOnFailure(err); - if (activePresetHandle.empty()) - { - ReturnErrorOnFailure(aEncoder.EncodeNull()); - } - else - { - ReturnErrorOnFailure(aEncoder.Encode(activePresetHandle)); - } + ReturnErrorOnFailure(aEncoder.Encode(activePresetHandle)); } break; case ScheduleTypes::Id: { @@ -1299,16 +1293,16 @@ bool emberAfThermostatClusterSetActivePresetRequestCallback( return true; } - ByteSpan newPresetHandle = commandData.presetHandle; + DataModel::Nullable newPresetHandle = commandData.presetHandle; // If the preset handle passed in the command is not present in the Presets attribute, return INVALID_COMMAND. - if (!IsPresetHandlePresentInPresets(delegate, newPresetHandle)) + if (!newPresetHandle.IsNull() && !IsPresetHandlePresentInPresets(delegate, newPresetHandle.Value())) { commandObj->AddStatus(commandPath, imcode::InvalidCommand); return true; } - CHIP_ERROR err = delegate->SetActivePresetHandle(DataModel::MakeNullable(newPresetHandle)); + CHIP_ERROR err = delegate->SetActivePresetHandle(newPresetHandle); if (err != CHIP_NO_ERROR) { @@ -1470,7 +1464,8 @@ imcode commitPresets(Delegate * delegate, EndpointId endpoint) // attribute. If a preset is not found with the same presetHandle, return INVALID_IN_STATE. If there is no ActivePresetHandle // attribute set, continue with other checks. uint8_t buffer[kPresetHandleSize]; - MutableByteSpan activePresetHandle(buffer); + MutableByteSpan activePresetHandleSpan(buffer); + auto activePresetHandle = DataModel::MakeNullable(activePresetHandleSpan); err = delegate->GetActivePresetHandle(activePresetHandle); @@ -1479,9 +1474,9 @@ imcode commitPresets(Delegate * delegate, EndpointId endpoint) return imcode::InvalidInState; } - if (!activePresetHandle.empty()) + if (!activePresetHandle.IsNull()) { - uint8_t count = CountPresetsInPendingListWithPresetHandle(delegate, activePresetHandle); + uint8_t count = CountPresetsInPendingListWithPresetHandle(delegate, activePresetHandle.Value()); if (count == 0) { return imcode::InvalidInState; diff --git a/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml index 546692b1a42030..6f75aa45e985f6 100644 --- a/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml @@ -481,7 +481,7 @@ limitations under the License. ID - + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index bfb1354849c9c4..52f43c048aed14 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -6994,7 +6994,7 @@ cluster Thermostat = 513 { } request struct SetActivePresetRequestRequest { - octet_string<16> presetHandle = 0; + nullable octet_string<16> presetHandle = 0; } response struct AtomicResponse = 253 { diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index 6f3e6f62d340e7..cf344db593f46a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -40637,16 +40637,16 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, commandArgs, timedInvokeTimeoutMs); } - public void setActivePresetRequest(DefaultClusterCallback callback, byte[] presetHandle) { + public void setActivePresetRequest(DefaultClusterCallback callback, @Nullable byte[] presetHandle) { setActivePresetRequest(callback, presetHandle, 0); } - public void setActivePresetRequest(DefaultClusterCallback callback, byte[] presetHandle, int timedInvokeTimeoutMs) { + public void setActivePresetRequest(DefaultClusterCallback callback, @Nullable byte[] presetHandle, int timedInvokeTimeoutMs) { final long commandId = 6L; ArrayList elements = new ArrayList<>(); final long presetHandleFieldID = 0L; - BaseTLVType presetHandletlvValue = new ByteArrayType(presetHandle); + BaseTLVType presetHandletlvValue = presetHandle != null ? new ByteArrayType(presetHandle) : new NullType(); elements.add(new StructElement(presetHandleFieldID, presetHandletlvValue)); StructType commandArgs = new StructType(elements); diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt index b9166c12e937a1..6f193e694ef34f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt @@ -504,7 +504,7 @@ class ThermostatCluster(private val controller: MatterController, private val en } suspend fun setActivePresetRequest( - presetHandle: ByteArray, + presetHandle: ByteArray?, timedInvokeTimeout: Duration? = null, ) { val commandId: UInt = 6u @@ -513,7 +513,7 @@ class ThermostatCluster(private val controller: MatterController, private val en tlvWriter.startStructure(AnonymousTag) val TAG_PRESET_HANDLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_PRESET_HANDLE_REQ), presetHandle) + presetHandle?.let { tlvWriter.put(ContextSpecificTag(TAG_PRESET_HANDLE_REQ), presetHandle) } tlvWriter.endStructure() val request: InvokeRequest = diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 6b8ecd1c82b577..624f42c8e80088 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -33168,10 +33168,10 @@ class SetActivePresetRequest(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="presetHandle", Tag=0, Type=bytes), + ClusterObjectFieldDescriptor(Label="presetHandle", Tag=0, Type=typing.Union[Nullable, bytes]), ]) - presetHandle: 'bytes' = b"" + presetHandle: 'typing.Union[Nullable, bytes]' = NullValue @dataclass class AtomicResponse(ClusterCommand): diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 5c869616268ecc..a5934b16975260 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -7929,7 +7929,7 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTRThermostatClusterSetActivePresetRequestParams : NSObject -@property (nonatomic, copy) NSData * _Nonnull presetHandle MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSData * _Nullable presetHandle MTR_PROVISIONALLY_AVAILABLE; /** * Controls whether the command is a timed command (using Timed Invoke). * diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 1334d8beba2654..5ae975508e9b75 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -22697,7 +22697,7 @@ - (instancetype)init { if (self = [super init]) { - _presetHandle = [NSData data]; + _presetHandle = nil; _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -22730,7 +22730,12 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader chip::app::Clusters::Thermostat::Commands::SetActivePresetRequest::Type encodableStruct; ListFreer listFreer; { - encodableStruct.presetHandle = AsByteSpan(self.presetHandle); + if (self.presetHandle == nil) { + encodableStruct.presetHandle.SetNull(); + } else { + auto & nonNullValue_0 = encodableStruct.presetHandle.SetNonNull(); + nonNullValue_0 = AsByteSpan(self.presetHandle); + } } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); 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 e18b64797bb595..c2c1697ce271f3 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -30149,7 +30149,7 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::SetActivePresetRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::Thermostat::Id; } - chip::ByteSpan presetHandle; + DataModel::Nullable presetHandle; CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -30164,7 +30164,7 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::SetActivePresetRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::Thermostat::Id; } - chip::ByteSpan presetHandle; + DataModel::Nullable presetHandle; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace SetActivePresetRequest 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 004bb29c546d1e..dc438df840c885 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -107995,7 +107995,11 @@ class ThermostatSetActivePresetRequest : public ClusterCommand { __auto_type * params = [[MTRThermostatClusterSetActivePresetRequestParams alloc] init]; params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; #if MTR_ENABLE_PROVISIONAL - params.presetHandle = [NSData dataWithBytes:mRequest.presetHandle.data() length:mRequest.presetHandle.size()]; + if (mRequest.presetHandle.IsNull()) { + params.presetHandle = nil; + } else { + params.presetHandle = [NSData dataWithBytes:mRequest.presetHandle.Value().data() length:mRequest.presetHandle.Value().size()]; + } #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount;