Skip to content

Commit

Permalink
Adding TimeoutMs to KeepActive command
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson committed Aug 22, 2024
1 parent 03a14ef commit 9aa72f8
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ limitations under the License.

<command source="client" code="0x80" name="KeepActive" optional="true" apiMaturity="provisional">
<description> The server SHALL attempt to keep the devices specified active for StayActiveDuration milliseconds when they are next active.</description>
<arg name="StayActiveDuration" type="int32u"/>
<arg id="0" name="StayActiveDuration" type="int32u"/>
<arg id="1" name="TimeoutMs" type="int32u"/>
</command>

<event side="server" code="0x00" name="StartUp" priority="critical" optional="true">
Expand Down
1 change: 1 addition & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,7 @@ cluster BridgedDeviceBasicInformation = 57 {

request struct KeepActiveRequest {
int32u stayActiveDuration = 0;
int32u timeoutMs = 1;
}

/** The server SHALL attempt to keep the devices specified active for StayActiveDuration milliseconds when they are next active. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15197,18 +15197,22 @@ public long initWithDevice(long devicePtr, int endpointId) {
return 0L;
}

public void keepActive(DefaultClusterCallback callback, Long stayActiveDuration) {
keepActive(callback, stayActiveDuration, 0);
public void keepActive(DefaultClusterCallback callback, Long stayActiveDuration, Long timeoutMs) {
keepActive(callback, stayActiveDuration, timeoutMs, 0);
}

public void keepActive(DefaultClusterCallback callback, Long stayActiveDuration, int timedInvokeTimeoutMs) {
public void keepActive(DefaultClusterCallback callback, Long stayActiveDuration, Long timeoutMs, int timedInvokeTimeoutMs) {
final long commandId = 128L;

ArrayList<StructElement> elements = new ArrayList<>();
final long stayActiveDurationFieldID = 0L;
BaseTLVType stayActiveDurationtlvValue = new UIntType(stayActiveDuration);
elements.add(new StructElement(stayActiveDurationFieldID, stayActiveDurationtlvValue));

final long timeoutMsFieldID = 1L;
BaseTLVType timeoutMstlvValue = new UIntType(timeoutMs);
elements.add(new StructElement(timeoutMsFieldID, timeoutMstlvValue));

StructType commandArgs = new StructType(elements);
invoke(new InvokeCallbackImpl(callback) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4543,7 +4543,7 @@ public static Command value(long id) throws NoSuchFieldError {
}
throw new NoSuchFieldError();
}
}public enum KeepActiveCommandField {StayActiveDuration(0),;
}public enum KeepActiveCommandField {StayActiveDuration(0),TimeoutMs(1),;
private final int id;
KeepActiveCommandField(int id) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24443,12 +24443,17 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {

CommandParameterInfo bridgedDeviceBasicInformationkeepActivestayActiveDurationCommandParameterInfo = new CommandParameterInfo("stayActiveDuration", Long.class, Long.class);
bridgedDeviceBasicInformationkeepActiveCommandParams.put("stayActiveDuration",bridgedDeviceBasicInformationkeepActivestayActiveDurationCommandParameterInfo);

CommandParameterInfo bridgedDeviceBasicInformationkeepActivetimeoutMsCommandParameterInfo = new CommandParameterInfo("timeoutMs", Long.class, Long.class);
bridgedDeviceBasicInformationkeepActiveCommandParams.put("timeoutMs",bridgedDeviceBasicInformationkeepActivetimeoutMsCommandParameterInfo);
InteractionInfo bridgedDeviceBasicInformationkeepActiveInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.BridgedDeviceBasicInformationCluster) cluster)
.keepActive((DefaultClusterCallback) callback
, (Long)
commandArguments.get("stayActiveDuration")
, (Long)
commandArguments.get("timeoutMs")
);
},
() -> new DelegatedDefaultClusterCallback(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,21 @@ class BridgedDeviceBasicInformationCluster(
object SubscriptionEstablished : AttributeListAttributeSubscriptionState()
}

suspend fun keepActive(stayActiveDuration: UInt, timedInvokeTimeout: Duration? = null) {
suspend fun keepActive(
stayActiveDuration: UInt,
timeoutMs: UInt,
timedInvokeTimeout: Duration? = null,
) {
val commandId: UInt = 128u

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

val TAG_STAY_ACTIVE_DURATION_REQ: Int = 0
tlvWriter.put(ContextSpecificTag(TAG_STAY_ACTIVE_DURATION_REQ), stayActiveDuration)

val TAG_TIMEOUT_MS_REQ: Int = 1
tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_MS_REQ), timeoutMs)
tlvWriter.endStructure()

val request: InvokeRequest =
Expand Down
1 change: 1 addition & 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.

2 changes: 2 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.

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.

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

1 change: 1 addition & 0 deletions zzz_generated/chip-tool/zap-generated/cluster/Commands.h

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 9aa72f8

Please sign in to comment.