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 4a44e51
Show file tree
Hide file tree
Showing 101 changed files with 2,007 additions and 1,647 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,31 @@ 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 %}
{%- 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 @@ -133,18 +146,23 @@ class {{cluster.name}}Cluster(private val endpointId: UShort) {
{%- 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 %}
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,17 @@ 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
}
// 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) {
// Implementation needs to be added here
}

suspend fun logout(timedInvokeTimeoutMs: Int) {
// 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 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 Down Expand Up @@ -78,12 +82,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
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 AdministratorCommissioningCluster(private val endpointId: UShort) {
class AdministratorCommissioningCluster(
private val controller: MatterController,
private val endpointId: UShort
) {
class AdminFabricIndexAttribute(val value: UByte?)

class AdminVendorIdAttribute(val value: UShort?)
Expand All @@ -38,32 +42,20 @@ class AdministratorCommissioningCluster(private val endpointId: UShort) {
discriminator: UShort,
iterations: UInt,
salt: ByteArray,
timedInvokeTimeoutMs: Int? = null
timedInvokeTimeoutMs: Int
) {
if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
// Do the action without timedInvokeTimeoutMs
}
// Implementation needs to be added here
}

suspend fun openBasicCommissioningWindow(
commissioningTimeout: UShort,
timedInvokeTimeoutMs: Int? = null
timedInvokeTimeoutMs: Int
) {
if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
// Do the action without timedInvokeTimeoutMs
}
}

suspend fun revokeCommissioning(timedInvokeTimeoutMs: Int? = null) {
if (timedInvokeTimeoutMs != null) {
// Do the action with timedInvokeTimeoutMs
} else {
// Do the action without timedInvokeTimeoutMs
}
// Implementation needs to be added here
}

suspend fun revokeCommissioning(timedInvokeTimeoutMs: Int) {
// Implementation needs to be added here
}

suspend fun readWindowStatusAttribute(): UByte {
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 AirQualityCluster(private val endpointId: UShort) {
class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) {
class GeneratedCommandListAttribute(val value: List<UInt>)

class AcceptedCommandListAttribute(val value: List<UInt>)
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 ApplicationBasicCluster(private val endpointId: UShort) {
class ApplicationBasicCluster(
private val controller: MatterController,
private val endpointId: UShort
) {
class ApplicationAttribute(val value: ApplicationBasicClusterApplicationStruct)

class AllowedVendorListAttribute(val value: List<UShort>)
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 ApplicationLauncherCluster(private val endpointId: UShort) {
class ApplicationLauncherCluster(
private val controller: MatterController,
private val endpointId: UShort
) {
class LauncherResponse(val status: UInt, val data: ByteArray?)

class CatalogListAttribute(val value: List<UShort>?)
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 AudioOutputCluster(private val endpointId: UShort) {
class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) {
class OutputListAttribute(val value: List<AudioOutputClusterOutputInfoStruct>)

class GeneratedCommandListAttribute(val value: List<UInt>)
Expand Down
Loading

0 comments on commit 4a44e51

Please sign in to comment.