Skip to content

Commit

Permalink
Update the preset handle field in the SetActivePresetRequestRequest c…
Browse files Browse the repository at this point in the history
…ommand to be nullable

- Update the deleagte API for getting the active preset handle to return a nullable handle
  • Loading branch information
nivi-apple committed Aug 20, 2024
1 parent 7f84a48 commit 1c7c98b
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MutableByteSpan> & activePresetHandle) override;

CHIP_ERROR SetActivePresetHandle(const DataModel::Nullable<ByteSpan> & newActivePresetHandle) override;

Expand Down
13 changes: 11 additions & 2 deletions examples/thermostat/linux/thermostat-delegate-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,18 @@ 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<MutableByteSpan> & activePresetHandle)
{
return CopySpanToMutableSpan(ByteSpan(mActivePresetHandleData, mActivePresetHandleDataSize), activePresetHandle);
if (mActivePresetHandleDataSize != 0)
{
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<ByteSpan> & newActivePresetHandle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/nxp/zap/thermostat_matter_wifi.matter
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions src/app/clusters/thermostat-server/thermostat-delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MutableByteSpan> & activePresetHandle) = 0;

/**
* @brief Set the ActivePresetHandle attribute value.
Expand Down
25 changes: 10 additions & 15 deletions src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
DataModel::Nullable<MutableByteSpan> 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: {
Expand Down Expand Up @@ -1299,16 +1293,16 @@ bool emberAfThermostatClusterSetActivePresetRequestCallback(
return true;
}

ByteSpan newPresetHandle = commandData.presetHandle;
DataModel::Nullable<ByteSpan> 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)
{
Expand Down Expand Up @@ -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);
DataModel::Nullable<MutableByteSpan> activePresetHandle = DataModel::MakeNullable(activePresetHandleSpan);

err = delegate->GetActivePresetHandle(activePresetHandle);

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ limitations under the License.

<command source="client" code="0x06" name="SetActivePresetRequest" optional="true">
<description>ID</description>
<arg id="0" name="PresetHandle" type="octet_string" length="16"/>
<arg id="0" name="PresetHandle" type="octet_string" length="16" isNullable="true"/>
</command>

<!-- Server Commands/Responses -->
Expand Down
2 changes: 1 addition & 1 deletion src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<StructElement> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion third_party/bouffalolab/repo
2 changes: 1 addition & 1 deletion third_party/nxp/nxp_matter_support
Submodule nxp_matter_support updated 40 files
+0 −35 examples/platform/k32w0/BUILD.gn
+0 −27 examples/platform/k32w0/app/BUILD.gn
+0 −28 examples/platform/k32w0/app/args.gni
+0 −448 examples/platform/k32w0/app/ldscripts/chip-k32w0x-linker.ld
+0 −116 examples/platform/k32w0/app/project_include/OpenThreadConfig.h
+0 −52 examples/platform/k32w0/app/support/BUILD.gn
+0 −274 examples/platform/k32w0/app/support/FreeRtosHooks.c
+0 −42 examples/platform/k32w0/app/support/FreeRtosHooks.h
+0 −184 examples/platform/k32w0/app/support/Memconfig.cpp
+0 −32 examples/platform/k32w0/args.gni
+0 −51 examples/platform/k32w0/common/CustomFactoryDataProvider.cpp
+0 −51 examples/platform/k32w0/common/CustomFactoryDataProvider.h
+ examples/platform/k32w0/scripts/demo_generated_factory_data/demo_factory_data_dut1.bin
+ examples/platform/k32w0/scripts/demo_generated_factory_data/demo_factory_data_dut2.bin
+0 −148 examples/platform/k32w0/scripts/detokenizer.py
+0 −74 examples/platform/k32w0/scripts/sign-outdir.py
+0 −272 examples/platform/k32w0/ssbl/BUILD.gn
+0 −1 examples/platform/k32w0/ssbl/stubs/eabi_stub.c
+0 −0 examples/platform/k32w0/ssbl/stubs/libcr_c.a
+0 −0 examples/platform/k32w0/ssbl/stubs/libcr_eabihelpers.a
+0 −31 examples/platform/k32w0/util/DefaultTestEventTriggerDelegate.cpp
+0 −86 examples/platform/k32w0/util/LEDWidget.cpp
+0 −36 examples/platform/k32w0/util/include/DefaultTestEventTriggerDelegate.h
+0 −41 examples/platform/k32w0/util/include/LEDWidget.h
+1 −0 github_sdk/k32w0/.gitignore
+37 −16 github_sdk/k32w0/manifest/west.yml
+4 −11 gn_build/BUILD.gn
+2 −2 gn_build/k32w0_sdk/BUILD.gn
+106 −117 gn_build/k32w0_sdk/k32w0_sdk.gni
+1 −1 gn_build/k32w0_sdk/nxp_arm.gni
+1 −1 gn_build/k32w0_sdk/nxp_executable.gni
+12 −14 gn_build/k32w1_sdk/BUILD.gn
+0 −272 gn_build/k32w1_sdk/core_sdk.gni
+0 −1 gn_build/k32w1_sdk/k32w1_executable.gni
+369 −56 gn_build/k32w1_sdk/k32w1_sdk.gni
+0 −297 gn_build/k32w1_sdk/middleware_sdk.gni
+1 −2 gn_build/k32w1_sdk/nxp_arm.gni
+1 −5 gn_build/k32w1_sdk/nxp_executable.gni
+2 −31 gn_build/nxp_sdk.gni
+3 −0 gn_build/rt_sdk/rt_sdk.gni
2 changes: 1 addition & 1 deletion third_party/silabs/matter_support
Submodule matter_support updated 126 files
2 changes: 1 addition & 1 deletion third_party/silabs/simplicity_sdk
Submodule simplicity_sdk updated 1976 files
2 changes: 1 addition & 1 deletion third_party/silabs/wifi_sdk
Submodule wifi_sdk updated 1190 files
2 changes: 1 addition & 1 deletion third_party/silabs/wiseconnect-wifi-bt-sdk

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c7c98b

Please sign in to comment.