Skip to content

Commit

Permalink
Adds the RVC Operational State cluster's GoHome command (#31242)
Browse files Browse the repository at this point in the history
* Added the RvcOpearationalState specific command GoHome to the XML.

* Regenerated files from XMLs.

* Regenerated files from XMLs after merging changes in master.

* Regenerated zap files.

* Added missing license to an all-clusters-app src file.

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Mar 13, 2024
1 parent ce9a539 commit 1281957
Show file tree
Hide file tree
Showing 25 changed files with 460 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3420,6 +3420,8 @@ cluster RvcOperationalState = 97 {
command Start(): OperationalCommandResponse = 2;
/** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */
command Resume(): OperationalCommandResponse = 3;
/** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */
command GoHome(): OperationalCommandResponse = 128;
}

/** Attributes and commands for scene configuration and manipulation. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
*
* 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 <air-quality-instance.h>

using namespace chip::app::Clusters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,8 @@ cluster RvcOperationalState = 97 {
command Start(): OperationalCommandResponse = 2;
/** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */
command Resume(): OperationalCommandResponse = 3;
/** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */
command GoHome(): OperationalCommandResponse = 128;
}

endpoint 0 {
Expand Down
2 changes: 2 additions & 0 deletions examples/rvc-app/rvc-common/rvc-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,8 @@ cluster RvcOperationalState = 97 {
command Start(): OperationalCommandResponse = 2;
/** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */
command Resume(): OperationalCommandResponse = 3;
/** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */
command GoHome(): OperationalCommandResponse = 128;
}

endpoint 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ both values from this cluster and from the base cluster.
<arg name="CommandResponseState" type="ErrorStateStruct"/>
</command>

<command source="client" code="0x80" name="GoHome" response="OperationalCommandResponse" optional="true">
<description>On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device.</description>
</command>

<event side="server" code="0x00" priority="critical" name="OperationalError" optional="false">
<description>OperationalError</description>
<field id="0" name="ErrorState" type="ErrorStateStruct" />
Expand Down
2 changes: 2 additions & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -3721,6 +3721,8 @@ cluster RvcOperationalState = 97 {
command Start(): OperationalCommandResponse = 2;
/** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */
command Resume(): OperationalCommandResponse = 3;
/** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */
command GoHome(): OperationalCommandResponse = 128;
}

/** Attributes and commands for scene configuration and manipulation. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25491,6 +25491,32 @@ public void onResponse(StructType invokeStructValue) {
}}, commandId, value, timedInvokeTimeoutMs);
}

public void goHome(OperationalCommandResponseCallback callback) {
goHome(callback, 0);
}

public void goHome(OperationalCommandResponseCallback callback, int timedInvokeTimeoutMs) {
final long commandId = 128L;

ArrayList<StructElement> elements = new ArrayList<>();
StructType value = new StructType(elements);
invoke(new InvokeCallbackImpl(callback) {
@Override
public void onResponse(StructType invokeStructValue) {
final long commandResponseStateFieldID = 0L;
ChipStructs.RvcOperationalStateClusterErrorStateStruct commandResponseState = null;
for (StructElement element: invokeStructValue.value()) {
if (element.contextTagNum() == commandResponseStateFieldID) {
if (element.value(BaseTLVType.class).type() == TLVType.Struct) {
StructType castingValue = element.value(StructType.class);
commandResponseState = ChipStructs.RvcOperationalStateClusterErrorStateStruct.decodeTlv(castingValue);
}
}
}
callback.onSuccess(commandResponseState);
}}, commandId, value, timedInvokeTimeoutMs);
}

public interface OperationalCommandResponseCallback extends BaseClusterCallback {
void onSuccess(ChipStructs.RvcOperationalStateClusterErrorStateStruct commandResponseState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8227,7 +8227,8 @@ public enum Command {
Pause(0L),
Stop(1L),
Start(2L),
Resume(3L),;
Resume(3L),
GoHome(128L),;
private final long id;
Command(long id) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22843,6 +22843,18 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {
);
rvcOperationalStateClusterInteractionInfoMap.put("resume", rvcOperationalStateresumeInteractionInfo);

Map<String, CommandParameterInfo> rvcOperationalStategoHomeCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo rvcOperationalStategoHomeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.RvcOperationalStateCluster) cluster)
.goHome((ChipClusters.RvcOperationalStateCluster.OperationalCommandResponseCallback) callback
);
},
() -> new DelegatedRvcOperationalStateClusterOperationalCommandResponseCallback(),
rvcOperationalStategoHomeCommandParams
);
rvcOperationalStateClusterInteractionInfoMap.put("goHome", rvcOperationalStategoHomeInteractionInfo);

commandMap.put("rvcOperationalState", rvcOperationalStateClusterInteractionInfoMap);

Map<String, InteractionInfo> scenesManagementClusterInteractionInfoMap = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,48 @@ class RvcOperationalStateCluster(
return OperationalCommandResponse(commandResponseState_decoded)
}

suspend fun goHome(timedInvokeTimeout: Duration? = null): OperationalCommandResponse {
val commandId: UInt = 128u

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
tlvWriter.endStructure()

val request: InvokeRequest =
InvokeRequest(
CommandPath(endpointId, clusterId = CLUSTER_ID, commandId),
tlvPayload = tlvWriter.getEncoded(),
timedRequest = timedInvokeTimeout
)

val response: InvokeResponse = controller.invoke(request)
logger.log(Level.FINE, "Invoke command succeeded: ${response}")

val tlvReader = TlvReader(response.payload)
tlvReader.enterStructure(AnonymousTag)
val TAG_COMMAND_RESPONSE_STATE: Int = 0
var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null

while (!tlvReader.isEndOfContainer()) {
val tag = tlvReader.peekElement().tag

if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {
commandResponseState_decoded =
RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)
} else {
tlvReader.skipElement()
}
}

if (commandResponseState_decoded == null) {
throw IllegalStateException("commandResponseState not found in TLV")
}

tlvReader.exitContainer()

return OperationalCommandResponse(commandResponseState_decoded)
}

suspend fun readPhaseListAttribute(): PhaseListAttribute {
val ATTRIBUTE_ID: UInt = 0u

Expand Down
6 changes: 6 additions & 0 deletions src/controller/python/chip/clusters/CHIPClusters.py

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

13 changes: 13 additions & 0 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.

8 changes: 8 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h

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

28 changes: 28 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm

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.

3 changes: 3 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRClusters.h

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

31 changes: 31 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm

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

28 changes: 28 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h

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

Loading

0 comments on commit 1281957

Please sign in to comment.