Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the RVC Operational State cluster's GoHome command #31242

Merged
merged 8 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,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 monitoring HEPA filters in a device */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,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 @@ -1100,6 +1100,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 @@ -3892,6 +3892,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 monitoring HEPA filters in a device */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26323,6 +26323,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 @@ -8509,7 +8509,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 @@ -22781,6 +22781,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> hepaFilterMonitoringClusterInteractionInfoMap = 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.

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

Loading
Loading