Skip to content

Commit

Permalink
Support timeout null instead of requiring ZERO for no timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Dec 12, 2023
1 parent 696f56a commit 04213c0
Show file tree
Hide file tree
Showing 81 changed files with 501 additions and 1,107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class {{cluster.name}}Cluster(private val controller: MatterController, private
{% if command.is_timed_invoke -%}
val timeoutMs: Duration = Duration.ofMillis(timedInvokeTimeoutMs.toLong())
{%- else -%}
val timeoutMs: Duration = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }
{%- endif %}

val tlvWriter = TlvWriter()
Expand Down Expand Up @@ -271,7 +271,6 @@ class {{cluster.name}}Cluster(private val controller: MatterController, private
{% endfor %}

else {
// Skip unknown tags
tlvReader.skipElement()
}
}
Expand Down Expand Up @@ -361,7 +360,7 @@ class {{cluster.name}}Cluster(private val controller: MatterController, private
{% if attribute.requires_timed_write -%}
val timeoutMs: Duration = Duration.ofMillis(timedWriteTimeoutMs.toLong())
{%- else -%}
val timeoutMs: Duration = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }
{%- endif %}

val tlvWriter = TlvWriter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ class AccessControlCluster(
timedWriteTimeoutMs: Int? = null
) {
val ATTRIBUTE_ID: UInt = 0u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startArray(AnonymousTag)
Expand Down Expand Up @@ -182,8 +181,7 @@ class AccessControlCluster(
timedWriteTimeoutMs: Int? = null
) {
val ATTRIBUTE_ID: UInt = 1u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startArray(AnonymousTag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class AccountLoginCluster(
if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) {
setupPIN_decoded = tlvReader.getString(tag)
} else {
// Skip unknown tags
tlvReader.skipElement()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo

suspend fun instantAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 0u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -79,8 +78,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo
timedInvokeTimeoutMs: Int? = null
) {
val commandId: UInt = 1u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -108,8 +106,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo

suspend fun startAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 2u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -139,8 +136,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo
timedInvokeTimeoutMs: Int? = null
) {
val commandId: UInt = 3u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -168,8 +164,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo

suspend fun stopAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 4u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand All @@ -194,8 +189,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo

suspend fun pauseAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 5u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -225,8 +219,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo
timedInvokeTimeoutMs: Int? = null
) {
val commandId: UInt = 6u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -254,8 +247,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo

suspend fun resumeAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 7u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand All @@ -280,8 +272,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo

suspend fun enableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 8u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -311,8 +302,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo
timedInvokeTimeoutMs: Int? = null
) {
val commandId: UInt = 9u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -340,8 +330,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo

suspend fun disableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 10u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -371,8 +360,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo
timedInvokeTimeoutMs: Int? = null
) {
val commandId: UInt = 11u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class ActivatedCarbonFilterMonitoringCluster(

suspend fun resetCondition(timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 0u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -255,8 +254,7 @@ class ActivatedCarbonFilterMonitoringCluster(

suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 4u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ class ApplicationLauncherCluster(
timedInvokeTimeoutMs: Int? = null
): LauncherResponse {
val commandId: UInt = 0u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -108,7 +107,6 @@ class ApplicationLauncherCluster(
}
}
} else {
// Skip unknown tags
tlvReader.skipElement()
}
}
Expand All @@ -127,8 +125,7 @@ class ApplicationLauncherCluster(
timedInvokeTimeoutMs: Int? = null
): LauncherResponse {
val commandId: UInt = 1u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -175,7 +172,6 @@ class ApplicationLauncherCluster(
}
}
} else {
// Skip unknown tags
tlvReader.skipElement()
}
}
Expand All @@ -194,8 +190,7 @@ class ApplicationLauncherCluster(
timedInvokeTimeoutMs: Int? = null
): LauncherResponse {
val commandId: UInt = 2u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down Expand Up @@ -242,7 +237,6 @@ class ApplicationLauncherCluster(
}
}
} else {
// Skip unknown tags
tlvReader.skipElement()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class AudioOutputCluster(private val controller: MatterController, private val e

suspend fun selectOutput(index: UByte, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 0u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand All @@ -69,8 +68,7 @@ class AudioOutputCluster(private val controller: MatterController, private val e

suspend fun renameOutput(index: UByte, name: String, timedInvokeTimeoutMs: Int? = null) {
val commandId: UInt = 1u
val timeoutMs: Duration =
timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedInvokeTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ class BallastConfigurationCluster(

suspend fun writeMinLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 16u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -258,8 +257,7 @@ class BallastConfigurationCluster(

suspend fun writeMaxLevelAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 17u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -341,8 +339,7 @@ class BallastConfigurationCluster(

suspend fun writeIntrinsicBallastFactorAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 20u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -427,8 +424,7 @@ class BallastConfigurationCluster(
timedWriteTimeoutMs: Int? = null
) {
val ATTRIBUTE_ID: UInt = 21u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -536,8 +532,7 @@ class BallastConfigurationCluster(

suspend fun writeLampTypeAttribute(value: String, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 48u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -614,8 +609,7 @@ class BallastConfigurationCluster(

suspend fun writeLampManufacturerAttribute(value: String, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 49u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -697,8 +691,7 @@ class BallastConfigurationCluster(

suspend fun writeLampRatedHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 50u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -780,8 +773,7 @@ class BallastConfigurationCluster(

suspend fun writeLampBurnHoursAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 51u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -858,8 +850,7 @@ class BallastConfigurationCluster(

suspend fun writeLampAlarmModeAttribute(value: UByte, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 52u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down Expand Up @@ -941,8 +932,7 @@ class BallastConfigurationCluster(

suspend fun writeLampBurnHoursTripPointAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) {
val ATTRIBUTE_ID: UInt = 53u
val timeoutMs: Duration =
timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) } ?: Duration.ZERO
val timeoutMs: Duration? = timedWriteTimeoutMs?.let { Duration.ofMillis(it.toLong()) }

val tlvWriter = TlvWriter()
tlvWriter.put(AnonymousTag, value)
Expand Down
Loading

0 comments on commit 04213c0

Please sign in to comment.