Skip to content

Commit

Permalink
[Kotlin] Make timedInvokeTimeoutMs field non-optional if mustUseTimed…
Browse files Browse the repository at this point in the history
… attribute is set
  • Loading branch information
yufengwangca committed Nov 3, 2023
1 parent 78c8704 commit d46c8b5
Show file tree
Hide file tree
Showing 101 changed files with 2,454 additions and 1,649 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@

package matter.devicecontroller.cluster.clusters

import matter.controller.MatterController
import matter.devicecontroller.cluster.structs.*
{% set typeLookup = idl | createLookupContext(cluster) %}
class {{cluster.name}}Cluster(private val endpointId: UShort) {
class {{cluster.name}}Cluster(private val controller: MatterController, private val endpointId: UShort) {

{%- set already_handled_command = [] -%}
{%- for command in cluster.commands | sort(attribute='code') -%}
Expand Down Expand Up @@ -101,19 +102,32 @@ class {{cluster.name}}Cluster(private val endpointId: UShort) {
{{field.name | lowfirst_except_acronym}}: {{encode_value(cluster, field | asEncodable(typeLookup), 0)}}
{%- if not loop.last -%}, {% endif %}
{%- endfor -%}
{%- if command.is_timed_invoke -%}
, timedInvokeTimeoutMs: Int)
{%- else -%}
, timedInvokeTimeoutMs: Int? = null)
{%- endif -%}
{%- else -%}
{%- if command.is_timed_invoke -%}
timedInvokeTimeoutMs: Int)
{%- else -%}
timedInvokeTimeoutMs: Int? = null)
{%- endif -%}
{%- endif -%}
{%- if command | hasResponse -%}
: {{callbackName}} {
{%- else %} {
{%- endif %}
{%- endif %}
val commandId = {{command.code}}L
{% if command.is_timed_invoke %}
// Implementation needs to be added here
{%- else %}
if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
// Do the action without timedInvokeTimeoutMs
}
}
{%- endif %}
}
{% endfor -%}

Expand All @@ -132,19 +146,24 @@ class {{cluster.name}}Cluster(private val endpointId: UShort) {
{% endif -%}
{%- if attribute.is_writable %}
{%- set encodable = attribute.definition | asEncodable(typeLookup) -%}
{%- set encodable2 = attribute.definition | asEncodable(typeLookup) -%}
{%- if not attribute.requires_timed_write %}
suspend fun write{{ attribute.definition.name | upfirst }}Attribute(
value: {{ encode_value_without_optional_nullable(cluster, encodable, 0) }}
) {
// Implementation needs to be added here
}
{% endif %}
{%- set encodable2 = attribute.definition | asEncodable(typeLookup) %}
suspend fun write{{ attribute.definition.name | upfirst }}Attribute(
value: {{ encode_value_without_optional_nullable(cluster, encodable2, 0) }},
{%- if attribute.requires_timed_write -%}
timedWriteTimeoutMs: Int
{%- else %}
timedWriteTimeoutMs: Int? = null
{%- endif %}
) {
{%- if attribute.requires_timed_write %}
// Implementation needs to be added here
{%- else %}
if (timedWriteTimeoutMs != null) {
// Do the action with timedWriteTimeoutMs
} else {
// Do the action without timedWriteTimeoutMs
}
{%- endif %}
}
{% endif %}
{%- if attribute.is_subscribable %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

package matter.devicecontroller.cluster.clusters

import matter.controller.MatterController
import matter.devicecontroller.cluster.structs.*

class AccessControlCluster(private val endpointId: UShort) {
class AccessControlCluster(
private val controller: MatterController,
private val endpointId: UShort
) {
class AclAttribute(val value: List<AccessControlClusterAccessControlEntryStruct>)

class ExtensionAttribute(val value: List<AccessControlClusterAccessControlExtensionStruct>?)
Expand All @@ -40,15 +44,15 @@ class AccessControlCluster(private val endpointId: UShort) {
// Implementation needs to be added here
}

suspend fun writeAclAttribute(value: List<AccessControlClusterAccessControlEntryStruct>) {
// Implementation needs to be added here
}

suspend fun writeAclAttribute(
value: List<AccessControlClusterAccessControlEntryStruct>,
timedWriteTimeoutMs: Int
timedWriteTimeoutMs: Int? = null
) {
// Implementation needs to be added here
if (timedWriteTimeoutMs != null) {
// Do the action with timedWriteTimeoutMs
} else {
// Do the action without timedWriteTimeoutMs
}
}

suspend fun subscribeAclAttribute(minInterval: Int, maxInterval: Int): AclAttribute {
Expand All @@ -65,17 +69,15 @@ class AccessControlCluster(private val endpointId: UShort) {
// Implementation needs to be added here
}

suspend fun writeExtensionAttribute(
value: List<AccessControlClusterAccessControlExtensionStruct>
) {
// Implementation needs to be added here
}

suspend fun writeExtensionAttribute(
value: List<AccessControlClusterAccessControlExtensionStruct>,
timedWriteTimeoutMs: Int
timedWriteTimeoutMs: Int? = null
) {
// Implementation needs to be added here
if (timedWriteTimeoutMs != null) {
// Do the action with timedWriteTimeoutMs
} else {
// Do the action without timedWriteTimeoutMs
}
}

suspend fun subscribeExtensionAttribute(minInterval: Int, maxInterval: Int): ExtensionAttribute {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

package matter.devicecontroller.cluster.clusters

import matter.controller.MatterController
import matter.devicecontroller.cluster.structs.*

class AccountLoginCluster(private val endpointId: UShort) {
class AccountLoginCluster(
private val controller: MatterController,
private val endpointId: UShort
) {
class GetSetupPINResponse(val setupPIN: String)

class GeneratedCommandListAttribute(val value: List<UInt>)
Expand All @@ -32,33 +36,23 @@ class AccountLoginCluster(private val endpointId: UShort) {

suspend fun getSetupPIN(
tempAccountIdentifier: String,
timedInvokeTimeoutMs: Int? = null
timedInvokeTimeoutMs: Int
): GetSetupPINResponse {
if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
// Do the action without timedInvokeTimeoutMs
}
val commandId = 0L

// Implementation needs to be added here
}

suspend fun login(
tempAccountIdentifier: String,
setupPIN: String,
timedInvokeTimeoutMs: Int? = null
) {
if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
// Do the action without timedInvokeTimeoutMs
}
}

suspend fun logout(timedInvokeTimeoutMs: Int? = null) {
if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
// Do the action without timedInvokeTimeoutMs
}
suspend fun login(tempAccountIdentifier: String, setupPIN: String, timedInvokeTimeoutMs: Int) {
val commandId = 2L

// Implementation needs to be added here
}

suspend fun logout(timedInvokeTimeoutMs: Int) {
val commandId = 3L

// Implementation needs to be added here
}

suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

package matter.devicecontroller.cluster.clusters

import matter.controller.MatterController
import matter.devicecontroller.cluster.structs.*

class ActionsCluster(private val endpointId: UShort) {
class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) {
class ActionListAttribute(val value: List<ActionsClusterActionStruct>)

class EndpointListsAttribute(val value: List<ActionsClusterEndpointListStruct>)
Expand All @@ -33,6 +34,8 @@ class ActionsCluster(private val endpointId: UShort) {
class AttributeListAttribute(val value: List<UInt>)

suspend fun instantAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId = 0L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -46,6 +49,8 @@ class ActionsCluster(private val endpointId: UShort) {
transitionTime: UShort,
timedInvokeTimeoutMs: Int? = null
) {
val commandId = 1L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -54,6 +59,8 @@ class ActionsCluster(private val endpointId: UShort) {
}

suspend fun startAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId = 2L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -67,6 +74,8 @@ class ActionsCluster(private val endpointId: UShort) {
duration: UInt,
timedInvokeTimeoutMs: Int? = null
) {
val commandId = 3L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -75,6 +84,8 @@ class ActionsCluster(private val endpointId: UShort) {
}

suspend fun stopAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId = 4L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -83,6 +94,8 @@ class ActionsCluster(private val endpointId: UShort) {
}

suspend fun pauseAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId = 5L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -96,6 +109,8 @@ class ActionsCluster(private val endpointId: UShort) {
duration: UInt,
timedInvokeTimeoutMs: Int? = null
) {
val commandId = 6L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -104,6 +119,8 @@ class ActionsCluster(private val endpointId: UShort) {
}

suspend fun resumeAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId = 7L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -112,6 +129,8 @@ class ActionsCluster(private val endpointId: UShort) {
}

suspend fun enableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId = 8L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -125,6 +144,8 @@ class ActionsCluster(private val endpointId: UShort) {
duration: UInt,
timedInvokeTimeoutMs: Int? = null
) {
val commandId = 9L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -133,6 +154,8 @@ class ActionsCluster(private val endpointId: UShort) {
}

suspend fun disableAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeoutMs: Int? = null) {
val commandId = 10L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand All @@ -146,6 +169,8 @@ class ActionsCluster(private val endpointId: UShort) {
duration: UInt,
timedInvokeTimeoutMs: Int? = null
) {
val commandId = 11L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

package matter.devicecontroller.cluster.clusters

import matter.controller.MatterController
import matter.devicecontroller.cluster.structs.*

class ActivatedCarbonFilterMonitoringCluster(private val endpointId: UShort) {
class ActivatedCarbonFilterMonitoringCluster(
private val controller: MatterController,
private val endpointId: UShort
) {
class LastChangedTimeAttribute(val value: UInt?)

class ReplacementProductListAttribute(
Expand All @@ -35,6 +39,8 @@ class ActivatedCarbonFilterMonitoringCluster(private val endpointId: UShort) {
class AttributeListAttribute(val value: List<UInt>)

suspend fun resetCondition(timedInvokeTimeoutMs: Int? = null) {
val commandId = 0L

if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
Expand Down Expand Up @@ -78,12 +84,12 @@ class ActivatedCarbonFilterMonitoringCluster(private val endpointId: UShort) {
// Implementation needs to be added here
}

suspend fun writeLastChangedTimeAttribute(value: UInt) {
// Implementation needs to be added here
}

suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeoutMs: Int) {
// Implementation needs to be added here
suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeoutMs: Int? = null) {
if (timedWriteTimeoutMs != null) {
// Do the action with timedWriteTimeoutMs
} else {
// Do the action without timedWriteTimeoutMs
}
}

suspend fun subscribeLastChangedTimeAttribute(
Expand Down
Loading

0 comments on commit d46c8b5

Please sign in to comment.